@gera2ld/tools-node 0.0.1 → 0.0.3
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/index.js +14 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import { readFile as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
``,
|
|
14
|
-
`[](https://www.jsdocs.io/package/${n.name})`
|
|
15
|
-
];
|
|
16
|
-
l.join(`
|
|
17
|
-
`) !== t.join(`
|
|
18
|
-
`) && (console.log(`[${n.name}] Badge updates:
|
|
19
|
-
|
|
20
|
-
${t.join(`
|
|
21
|
-
`)}`), s < 0 ? e.splice(1, e[1] ? 0 : 1, "", ...t, "") : e.splice(i, s - i, ...t), a && (await c(o, e.join(`
|
|
22
|
-
`)), console.log(`[${n.name}] New badges written`)));
|
|
1
|
+
import { readFile as e, writeFile as t } from "node:fs/promises";
|
|
2
|
+
//#region src/badge.ts
|
|
3
|
+
async function n(n, r) {
|
|
4
|
+
let i = `${n.path}/README.md`, a = (await e(i, "utf8")).split("\n"), o = a.indexOf(""), s;
|
|
5
|
+
if (o > 0 && (o += 1, a[o].includes("![") || (o = -1)), o < 0) s = -1;
|
|
6
|
+
else for (s = o + 1; s < a.length && a[s].includes("!["); s += 1);
|
|
7
|
+
let c = s < 0 ? [] : a.slice(o, s), l = [
|
|
8
|
+
`[](https://npm.im/${n.name})`,
|
|
9
|
+
``,
|
|
10
|
+
`[](https://www.jsdocs.io/package/${n.name})`
|
|
11
|
+
];
|
|
12
|
+
c.join("\n") !== l.join("\n") && (console.log(`[${n.name}] Badge updates:\n\n${l.join("\n")}`), s < 0 ? a.splice(1, +!a[1], "", ...l, "") : a.splice(o, s - o, ...l), r && (await t(i, a.join("\n")), console.log(`[${n.name}] New badges written`)));
|
|
23
13
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { n as updateBadges };
|