Ran linter
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
const fs = require("fs-extra")
|
||||
const path = require("path")
|
||||
const chalk = require("chalk")
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const {
|
||||
attempt,
|
||||
readSnippets,
|
||||
@ -8,36 +8,35 @@ const {
|
||||
getSection,
|
||||
getTitle,
|
||||
getTextualContent
|
||||
} = require("./util");
|
||||
} = require('./util');
|
||||
|
||||
console.time("Extractor");
|
||||
console.time('Extractor');
|
||||
|
||||
attempt("snippet_data.json generation", () => {
|
||||
attempt('snippet_data.json generation', () => {
|
||||
const output = Object.entries(readSnippets()).map(([name, contents]) => {
|
||||
const title = getTitle(contents);
|
||||
const text = getTextualContent(contents);
|
||||
const codeBlocks = getCodeBlocks(contents);
|
||||
const notes = getSection("#### Notes", contents, false)
|
||||
.split("\n")
|
||||
.map(v => v.replace(/[*-] /g, ""))
|
||||
.filter(v => v.trim() !== "")
|
||||
|
||||
const notes = getSection('#### Notes', contents, false)
|
||||
.split('\n')
|
||||
.map(v => v.replace(/[*-] /g, ''))
|
||||
.filter(v => v.trim() !== '');
|
||||
|
||||
return {
|
||||
name,
|
||||
title,
|
||||
text,
|
||||
codeBlocks,
|
||||
expertise: parseInt(
|
||||
(contents.match(/<!--\s*expertise:\s*\(*(.+)\)*/) || [])[1],
|
||||
10
|
||||
),
|
||||
tags: (contents.match(/<!--\s*tags:\s*\(*(.+)\)*\s*-->/) || [])[1].split(",").map(v => v.trim()),
|
||||
expertise: parseInt((contents.match(/<!--\s*expertise:\s*\(*(.+)\)*/) || [])[1], 10),
|
||||
tags: (contents.match(/<!--\s*tags:\s*\(*(.+)\)*\s*-->/) || [])[1]
|
||||
.split(',')
|
||||
.map(v => v.trim()),
|
||||
notes
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
fs.writeFileSync("./data/snippet_data.json", JSON.stringify(output, null, 2))
|
||||
})
|
||||
fs.writeFileSync('./data/snippet_data.json', JSON.stringify(output, null, 2));
|
||||
});
|
||||
|
||||
console.log(`${chalk.green("SUCCESS!")} snippet_data.json file generated!`);
|
||||
console.timeEnd("Extractor");
|
||||
console.log(`${chalk.green('SUCCESS!')} snippet_data.json file generated!`);
|
||||
console.timeEnd('Extractor');
|
||||
|
||||
Reference in New Issue
Block a user