nicevg 0.18.1 → 0.19.0
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/cli.js +16 -5
- package/dist/cli.js.map +1 -1
- package/native/darwin-arm64/libnicevg_ffi.dylib +0 -0
- package/native/darwin-x64/libnicevg_ffi.dylib +0 -0
- package/native/linux-arm64/libnicevg_ffi.so +0 -0
- package/native/linux-x64/libnicevg_ffi.so +0 -0
- package/native/win32-x64/nicevg_ffi.dll +0 -0
- package/package.json +1 -1
- package/src/cli.ts +16 -5
package/dist/cli.js
CHANGED
|
@@ -4,19 +4,30 @@
|
|
|
4
4
|
* native library, out on stdout. Issues left go to stderr, one per line;
|
|
5
5
|
* the exit status is 0 with none left, 1 with some, and 2 for bad input.
|
|
6
6
|
*/
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
7
|
+
import { readFileSync, writeSync } from "node:fs";
|
|
8
8
|
import { NicevgError, render } from "./index.js";
|
|
9
9
|
const ABOUT = "Repair mechanical layout errors in an SVG diagram read from stdin, move nodes a little so connectors bend, cross and crowd less, and write the result to stdout";
|
|
10
10
|
const USAGE = "Usage: nicevg";
|
|
11
|
+
/** Writes to stdout, as nothing once the reader has gone, as `head` does. */
|
|
12
|
+
function print(text) {
|
|
13
|
+
try {
|
|
14
|
+
writeSync(1, text);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error.code !== "EPIPE") {
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
11
22
|
function main(args) {
|
|
12
23
|
for (const arg of args) {
|
|
13
24
|
if (arg === "-h" || arg === "--help") {
|
|
14
|
-
|
|
25
|
+
print(`${ABOUT}\n\n${USAGE}\n\nOptions:\n -h, --help Print help\n -V, --version Print version\n`);
|
|
15
26
|
return 0;
|
|
16
27
|
}
|
|
17
28
|
if (arg === "-V" || arg === "--version") {
|
|
18
29
|
const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
19
|
-
|
|
30
|
+
print(`nicevg ${version}\n`);
|
|
20
31
|
return 0;
|
|
21
32
|
}
|
|
22
33
|
}
|
|
@@ -35,12 +46,12 @@ function main(args) {
|
|
|
35
46
|
}
|
|
36
47
|
throw error;
|
|
37
48
|
}
|
|
38
|
-
|
|
49
|
+
print(`${svg}\n`);
|
|
39
50
|
for (const issue of svg.report.issues) {
|
|
40
51
|
process.stderr.write(`${issue.code}: ${issue.message}\n`);
|
|
41
52
|
}
|
|
42
53
|
return svg.report.valid ? 0 : 1;
|
|
43
54
|
}
|
|
44
|
-
// Set rather than exit, so
|
|
55
|
+
// Set rather than exit, so stderr finishes writing first.
|
|
45
56
|
process.exitCode = main(process.argv.slice(2));
|
|
46
57
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,KAAK,GACT,iKAAiK,CAAC;AACpK,MAAM,KAAK,GAAG,eAAe,CAAC;AAE9B,6EAA6E;AAC7E,SAAS,KAAK,CAAC,IAAY;IACzB,IAAI,CAAC;QACH,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACtD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CA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AG,GAAG,IAAI,CAAC,CAAC;IAClB,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,0DAA0D;AAC1D,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* the exit status is 0 with none left, 1 with some, and 2 for bad input.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { readFileSync } from "node:fs";
|
|
8
|
+
import { readFileSync, writeSync } from "node:fs";
|
|
9
9
|
|
|
10
10
|
import { NicevgError, render } from "./index.ts";
|
|
11
11
|
|
|
@@ -13,15 +13,26 @@ const ABOUT =
|
|
|
13
13
|
"Repair mechanical layout errors in an SVG diagram read from stdin, move nodes a little so connectors bend, cross and crowd less, and write the result to stdout";
|
|
14
14
|
const USAGE = "Usage: nicevg";
|
|
15
15
|
|
|
16
|
+
/** Writes to stdout, as nothing once the reader has gone, as `head` does. */
|
|
17
|
+
function print(text: string): void {
|
|
18
|
+
try {
|
|
19
|
+
writeSync(1, text);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if ((error as NodeJS.ErrnoException).code !== "EPIPE") {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
function main(args: string[]): number {
|
|
17
28
|
for (const arg of args) {
|
|
18
29
|
if (arg === "-h" || arg === "--help") {
|
|
19
|
-
|
|
30
|
+
print(`${ABOUT}\n\n${USAGE}\n\nOptions:\n -h, --help Print help\n -V, --version Print version\n`);
|
|
20
31
|
return 0;
|
|
21
32
|
}
|
|
22
33
|
if (arg === "-V" || arg === "--version") {
|
|
23
34
|
const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
24
|
-
|
|
35
|
+
print(`nicevg ${version}\n`);
|
|
25
36
|
return 0;
|
|
26
37
|
}
|
|
27
38
|
}
|
|
@@ -40,12 +51,12 @@ function main(args: string[]): number {
|
|
|
40
51
|
}
|
|
41
52
|
throw error;
|
|
42
53
|
}
|
|
43
|
-
|
|
54
|
+
print(`${svg}\n`);
|
|
44
55
|
for (const issue of svg.report.issues) {
|
|
45
56
|
process.stderr.write(`${issue.code}: ${issue.message}\n`);
|
|
46
57
|
}
|
|
47
58
|
return svg.report.valid ? 0 : 1;
|
|
48
59
|
}
|
|
49
60
|
|
|
50
|
-
// Set rather than exit, so
|
|
61
|
+
// Set rather than exit, so stderr finishes writing first.
|
|
51
62
|
process.exitCode = main(process.argv.slice(2));
|