fscr 6.2.1 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/generateToc.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
import tocPkg from "markdown-toc";
|
|
5
5
|
const toc = tocPkg.default || tocPkg;
|
|
6
|
-
const joyRead = new JoyCon({
|
|
7
|
-
// Stop reading at parent dir
|
|
8
|
-
// i.e. Only read file from process.cwd()
|
|
9
|
-
stopDir: path.dirname(process.cwd())
|
|
10
|
-
});
|
|
11
6
|
import { writeFile } from "./utils/helpers.js";
|
|
12
7
|
// const projectDir = process.cwd();
|
|
13
8
|
|
|
14
9
|
const generateToc = async () => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
data
|
|
18
|
-
} = joyRead.loadSync(["fscripts.md"]);
|
|
19
|
-
if (!filepath) {
|
|
10
|
+
const filepath = path.resolve(process.cwd(), "fscripts.md");
|
|
11
|
+
if (!fs.existsSync(filepath)) {
|
|
20
12
|
console.warn(`${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
21
13
|
${chalk.green("Please run 'fsr generate' to get started!")}`);
|
|
22
14
|
process.exit(0);
|
|
23
15
|
return null;
|
|
24
|
-
}
|
|
16
|
+
}
|
|
17
|
+
const data = fs.readFileSync(filepath, "utf-8");
|
|
18
|
+
if (data) {
|
|
25
19
|
console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
26
20
|
let newFile = ``;
|
|
27
21
|
let tocSplit = data.split("<!-- end toc -->");
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
import tocPkg from "markdown-toc";
|
|
5
5
|
const toc = tocPkg.default || tocPkg;
|
|
6
|
-
const joyRead = new JoyCon({
|
|
7
|
-
// Stop reading at parent dir
|
|
8
|
-
// i.e. Only read file from process.cwd()
|
|
9
|
-
stopDir: path.dirname(process.cwd())
|
|
10
|
-
});
|
|
11
6
|
import { writeFile } from "../utils/helpers.js";
|
|
12
7
|
// const projectDir = process.cwd();
|
|
13
8
|
|
|
14
9
|
const generateToc = async (fileToLoad = "fscripts.md") => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
data
|
|
18
|
-
} = joyRead.loadSync([fileToLoad]);
|
|
19
|
-
if (!filepath) {
|
|
10
|
+
const filepath = path.resolve(process.cwd(), fileToLoad);
|
|
11
|
+
if (!fs.existsSync(filepath)) {
|
|
20
12
|
console.warn(`${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
21
13
|
${chalk.green("Please run 'fsr generate' to get started!")}`);
|
|
22
14
|
process.exit(0);
|
|
23
15
|
return null;
|
|
24
|
-
}
|
|
16
|
+
}
|
|
17
|
+
const data = fs.readFileSync(filepath, "utf-8");
|
|
18
|
+
if (data) {
|
|
25
19
|
console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
26
20
|
let newFile = ``;
|
|
27
21
|
let tocSplit = data.split("<!-- end toc -->");
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import JoyCon from "joycon";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import chalk from "chalk";
|
|
4
|
-
|
|
5
|
-
// Stop reading at parent dir
|
|
6
|
-
// i.e. Only read file from process.cwd()
|
|
7
|
-
stopDir: path.dirname(process.cwd())
|
|
8
|
-
});
|
|
3
|
+
import fs from "fs";
|
|
9
4
|
const flattenObject = (obj, prefix = "") => Object.keys(obj).reduce((acc, k) => {
|
|
10
5
|
const pre = prefix.length ? prefix + "." : "";
|
|
11
6
|
if (typeof obj[k] === "object") Object.assign(acc, flattenObject(obj[k], pre + k));else acc[pre + k] = obj[k];
|
|
@@ -70,11 +65,8 @@ let parse = function (mdContent) {
|
|
|
70
65
|
};
|
|
71
66
|
};
|
|
72
67
|
const parseScriptFile = async () => {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
data
|
|
76
|
-
} = joyRead.loadSync(["fscripts.md"]);
|
|
77
|
-
if (!filepath) {
|
|
68
|
+
const data = await fs.readFileSync(path.resolve(process.cwd(), "fscripts.md"), "utf-8");
|
|
69
|
+
if (!data) {
|
|
78
70
|
// console.warn(
|
|
79
71
|
// `${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
80
72
|
// ${chalk.green("Please run 'fsr generate' to get started!")}`
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import JoyCon from "joycon";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import chalk from "chalk";
|
|
4
3
|
import fs from "fs";
|
|
5
|
-
const joyRead = new JoyCon({
|
|
6
|
-
// Stop reading at parent dir
|
|
7
|
-
// i.e. Only read file from process.cwd()
|
|
8
|
-
stopDir: path.dirname(process.cwd())
|
|
9
|
-
});
|
|
10
4
|
const flattenObject = (obj, prefix = "") => Object.keys(obj).reduce((acc, k) => {
|
|
11
5
|
const pre = prefix.length ? prefix + "." : "";
|
|
12
6
|
if (typeof obj[k] === "object") Object.assign(acc, flattenObject(obj[k], pre + k));else acc[pre + k] = obj[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fscr",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"description": "Runs the fscripts.md file",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"ink-select-input": "^6.2.0",
|
|
70
70
|
"inquirer": "^12.9.6",
|
|
71
71
|
"is-builtin-module": "^5.0.0",
|
|
72
|
-
"joycon": "^3.1.1",
|
|
73
72
|
"json-colorz": "^0.2.7",
|
|
74
73
|
"markdown-toc": "^1.2.0",
|
|
75
74
|
"marked": "^16.3.0",
|