1 | const chalk = require("chalk");
|
2 | const inquirer = require("inquirer");
|
3 |
|
4 | const { appendToFile, writeFile, boxInform, readJson, readFile } = require("./helpers.js");
|
5 | const path = require("path");
|
6 | const projectDir = process.cwd();
|
7 | const packagePath = path.join(projectDir, "package.json");
|
8 |
|
9 | const gen = { scripts: [] };
|
10 | let mdfile = `# First category of scripts
|
11 |
|
12 | Welcome to your new amazing fscripts.md file. It replaces the headaches of npm scripts! But so much more.
|
13 | `;
|
14 |
|
15 | gen.init = async () => {
|
16 | try {
|
17 | gen.packageJson = await readJson(packagePath);
|
18 | Object.keys(gen.packageJson.scripts).forEach(scriptName => {
|
19 | mdfile += `\n## ${scriptName}\n\n${
|
20 | gen.packageJson.scripts[scriptName]
|
21 | }\n\n\`\`\`bash\n${gen.packageJson.scripts[scriptName]}\n\`\`\`\n\n`;
|
22 | });
|
23 | await writeFile("./sample.fscripts.md", mdfile);
|
24 | } catch (err) {
|
25 | console.error(err);
|
26 | }
|
27 | };
|
28 |
|
29 | module.exports = gen.init;
|