Skip to content

Commit

Permalink
move tag types to helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Nov 11, 2022
1 parent d337805 commit 0f7ffea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 6 additions & 3 deletions scripts/build-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const {
redirectsFilenames,
SCRIPTLETS_SRC_RELATIVE_DIR_PATH,
REDIRECTS_SRC_RELATIVE_DIR_PATH,
SCRIPTLET_TYPE,
TRUSTED_SCRIPTLET_TYPE,
REDIRECT_TYPE,
} = require('./constants');

const STATIC_REDIRECTS_FILENAME = 'static-redirects.yml';
Expand Down Expand Up @@ -65,9 +68,9 @@ const manageDataFromFiles = () => {
.concat(dataFromRedirectsFiles)
.flat(Infinity);

const scriptletsData = fullData.filter(({ type }) => type === 'scriptlet');
const trustedScriptletsData = fullData.filter(({ type }) => type === 'trustedScriptlet');
const redirectsData = fullData.filter(({ type }) => type === 'redirect');
const scriptletsData = fullData.filter(({ type }) => type === SCRIPTLET_TYPE);
const trustedScriptletsData = fullData.filter(({ type }) => type === TRUSTED_SCRIPTLET_TYPE);
const redirectsData = fullData.filter(({ type }) => type === REDIRECT_TYPE);

return {
scriptletsData,
Expand Down
13 changes: 10 additions & 3 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const path = require('path');
const fs = require('fs-extra');
const dox = require('dox');

const SCRIPTLET_TYPE = 'scriptlet';
const TRUSTED_SCRIPTLET_TYPE = 'trustedScriptlet';
const REDIRECT_TYPE = 'redirect';

/**
* Asynchronously writes data to a file, replacing the file if it already exists.
*
Expand Down Expand Up @@ -54,9 +58,9 @@ const getDescribingCommentTags = (filePath) => {
return false;
}
const [base] = tags;
return base?.type === 'scriptlet'
|| base?.type === 'trustedScriptlet'
|| base?.type === 'redirect';
return base?.type === SCRIPTLET_TYPE
|| base?.type === TRUSTED_SCRIPTLET_TYPE
|| base?.type === REDIRECT_TYPE;
});

if (describingComment.length === 0) {
Expand Down Expand Up @@ -123,4 +127,7 @@ module.exports = {
writeFile,
getFilesList,
getDataFromFiles,
SCRIPTLET_TYPE,
TRUSTED_SCRIPTLET_TYPE,
REDIRECT_TYPE,
};

0 comments on commit 0f7ffea

Please sign in to comment.