diff --git a/scripts/build.js b/scripts/build.js
index a8e917c54..6679bbb44 100644
--- a/scripts/build.js
+++ b/scripts/build.js
@@ -45,10 +45,10 @@ if (
.readdirSync(SNIPPETS_ARCHIVE_PATH)
.sort((a, b) => a.toLowerCase() - b.toLowerCase());
// Store the data read from each snippet in the appropriate object
- for (const name of snippetFilenames.filter(s => s !== 'README.md')) {
+ for (const name of snippetFilenames.filter(s => s !== 'README.md'))
snippets[name] = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, name), 'utf8');
- }
- } catch (err) {
+ }
+ catch (err) {
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
process.exit(1);
}
@@ -65,13 +65,13 @@ if (
);
output += misc.hr();
- for (const snippet of Object.entries(snippets)) {
+ for (const snippet of Object.entries(snippets))
output += makeExamples(snippet[1]);
- }
// Write to the README file of the archive
fs.writeFileSync(path.join(SNIPPETS_ARCHIVE_PATH, 'README.md'), output);
- } catch (err) {
+ }
+ catch (err) {
console.log(`${chalk.red('ERROR!')} During README generation for snippets archive: ${err}`);
process.exit(1);
}
@@ -110,7 +110,8 @@ snippets = util.readSnippets(SNIPPETS_PATH);
try {
startPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-start.md'), 'utf8');
endPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-end.md'), 'utf8');
-} catch (err) {
+}
+catch (err) {
console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`);
process.exit(1);
}
@@ -170,7 +171,8 @@ try {
output += `\n${endPart}\n`;
// Write to the README file
fs.writeFileSync('README.md', output);
-} catch (err) {
+}
+catch (err) {
console.log(`${chalk.red('ERROR!')} During README generation: ${err}`);
process.exit(1);
}
diff --git a/scripts/lint.js b/scripts/lint.js
index 4f96de1f3..ada4edd2b 100644
--- a/scripts/lint.js
+++ b/scripts/lint.js
@@ -28,9 +28,9 @@ try {
// turn it into an object so we can add data to it to be used in a different scope
.map(name => ({ name }));
- if (!fs.existsSync(TEMP_PATH)) {
+ if (!fs.existsSync(TEMP_PATH))
fs.mkdirSync(TEMP_PATH);
- }
+
for (const snippet of snippets) {
snippet.data = fs.readFileSync(path.join(SNIPPETS_PATH, snippet.name), 'utf8');
@@ -55,7 +55,7 @@ try {
`semistandard "${TEMP_PATH}" --fix & ` +
`prettier "${TEMP_PATH}/*.js" --single-quote --print-width=100 --write`;
- cp.exec(cmd, {}, (err, stdout, stderr) => {
+ cp.exec(cmd, {}, () => {
// Loop through each snippet now that semistandard and prettier did their job
for (const snippet of snippets) {
// an array to store each linted code block (definition + example)
@@ -77,7 +77,8 @@ try {
console.log(`${chalk.green('SUCCESS!')} Snippet files linted!`);
console.timeEnd('Linter');
});
-} catch (err) {
+}
+catch (err) {
console.log(`${chalk.red('ERROR!')} During linting: ${err}`);
process.exit(1);
}
diff --git a/scripts/tag.js b/scripts/tag.js
index 8b0142c0a..6953b4692 100644
--- a/scripts/tag.js
+++ b/scripts/tag.js
@@ -30,22 +30,25 @@ tagDbStats = Object.entries(tagDbData).reduce((acc, val) => {
}, {});
// Update the listing of snippets in tag_database and log the statistics, along with missing scripts
try {
- for (let snippet of Object.entries(snippets))
+ for (let snippet of Object.entries(snippets)) {
if (
tagDbData.hasOwnProperty(snippet[0].slice(0, -3)) &&
tagDbData[snippet[0].slice(0, -3)].join(',').trim()
- )
+ ) {
output += `${snippet[0].slice(0, -3)}:${tagDbData[snippet[0].slice(0, -3)]
.join(',')
.trim()}\n`;
+ }
else {
output += `${snippet[0].slice(0, -3)}:uncategorized\n`;
missingTags++;
console.log(`${chalk.yellow('Tagged uncategorized:')} ${snippet[0].slice(0, -3)}`);
}
+ }
// Write to tag_database
fs.writeFileSync('tag_database', output);
-} catch (err) {
+}
+catch (err) {
// Handle errors (hopefully not!)
console.log(`${chalk.red('ERROR!')} During tag_database generation: ${err}`);
process.exit(1);
diff --git a/scripts/util.js b/scripts/util.js
index 538758603..1be96e75a 100644
--- a/scripts/util.js
+++ b/scripts/util.js
@@ -31,7 +31,8 @@ const getFilesInDir = (directoryPath, withPath, exclude = null) => {
}, []);
}
return directoryFilenames;
- } catch (err) {
+ }
+ catch (err) {
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
process.exit(1);
}
@@ -45,7 +46,8 @@ const readSnippets = snippetsPath => {
try {
for (let snippet of snippetFilenames)
snippets[snippet] = fs.readFileSync(path.join(snippetsPath, snippet), 'utf8');
- } catch (err) {
+ }
+ catch (err) {
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
process.exit(1);
}
@@ -68,7 +70,8 @@ const readTags = () => {
return data;
})
);
- } catch (err) {
+ }
+ catch (err) {
// Handle errors (hopefully not!)
console.log(`${chalk.red('ERROR!')} During tag database loading: ${err}`);
process.exit(1);
@@ -82,9 +85,9 @@ const optimizeNodes = (data, regexp, replacer) => {
do {
output = output.replace(regexp, replacer);
count = 0;
- while (regexp.exec(output) !== null) {
+ while (regexp.exec(output) !== null)
++count;
- }
+
} while (count > 0);
return output;
};
@@ -116,9 +119,9 @@ const getCodeBlocks = str => {
const results = [];
let m = null;
while ((m = regex.exec(str)) !== null) {
- if (m.index === regex.lastIndex) {
+ if (m.index === regex.lastIndex)
regex.lastIndex += 1;
- }
+
m.forEach((match, groupIndex) => {
results.push(match);
});
@@ -131,9 +134,9 @@ const getTextualContent = str => {
const results = [];
let m = null;
while ((m = regex.exec(str)) !== null) {
- if (m.index === regex.lastIndex) {
+ if (m.index === regex.lastIndex)
regex.lastIndex += 1;
- }
+
m.forEach((match, groupIndex) => {
results.push(match);
});
diff --git a/scripts/web.js b/scripts/web.js
index 57a477dca..9d17c7699 100644
--- a/scripts/web.js
+++ b/scripts/web.js
@@ -47,12 +47,12 @@ const generateSnippetCard = (
${
addCornerTag
? `
`
+ snippetKey[1].includes('advanced')
+ ? 'advanced'
+ : snippetKey[1].includes('beginner')
+ ? 'beginner'
+ : 'intermediate'
+ }">`
: ''
}
${md
@@ -109,9 +109,10 @@ sass.render(
if (!err2) console.log(`${chalk.green('SUCCESS!')} style.css file generated!`);
else console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`);
});
- } else {
- console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`);
}
+ else
+ console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`);
+
}
);
// Set variables for paths
@@ -147,7 +148,8 @@ try {
'static-page-start.html',
'static-page-end.html'
].map(filename => fs.readFileSync(path.join(staticPartsPath, filename), 'utf8'));
-} catch (err) {
+}
+catch (err) {
// Handle errors (hopefully not!)
console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`);
process.exit(1);
@@ -169,7 +171,7 @@ try {
.replace(//g, '')
.replace(/<\/p>/g, '') +
'