linegauge 0.5.0 → 0.5.1
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/README.md +1 -1
- package/dist/check.js +31 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,7 +169,7 @@ its own suite — which this package passes. The runner reports that as a failur
|
|
|
169
169
|
to the incumbent an unexpected pass means a stale annotation; it is counted here as the
|
|
170
170
|
pass it is, and marked rather than left to look like the ones beside it.
|
|
171
171
|
|
|
172
|
-
Weight, installed and tree-inclusive: **
|
|
172
|
+
Weight, installed and tree-inclusive: **85,473 bytes** against **194,329** for the incumbents it replaces — a ratio of **0.4398**.
|
|
173
173
|
## Where it sits
|
|
174
174
|
|
|
175
175
|
Plugins register under the `widths` key, against the one schema the whole family shares.
|
package/dist/check.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
1
2
|
import { resolve } from 'node:path';
|
|
2
3
|
import { pathToFileURL } from 'node:url';
|
|
3
4
|
import { overrides, PluginError, register, setOverrides, validate } from './plugin.js';
|
|
@@ -5,6 +6,33 @@ import { width } from './width.js';
|
|
|
5
6
|
export const EXIT_OK = 0;
|
|
6
7
|
export const EXIT_RUNTIME = 1;
|
|
7
8
|
export const EXIT_USAGE = 2;
|
|
9
|
+
const USAGE = 'usage: linegauge check <plugin-file>\n';
|
|
10
|
+
const HELP = `${USAGE}
|
|
11
|
+
Load a plugin file, validate it against the family schema, register it, and report what
|
|
12
|
+
linegauge does with it. Exit 0 when it contributes, 1 on a refusal (with a code and a fix), 2 on
|
|
13
|
+
a usage error.
|
|
14
|
+
|
|
15
|
+
-h, --help show this help
|
|
16
|
+
-V, --version print the version
|
|
17
|
+
`;
|
|
18
|
+
function version() {
|
|
19
|
+
return JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
20
|
+
}
|
|
21
|
+
function target(arg, write) {
|
|
22
|
+
if (arg === '--help' || arg === '-h') {
|
|
23
|
+
write(HELP);
|
|
24
|
+
return EXIT_OK;
|
|
25
|
+
}
|
|
26
|
+
if (arg === '--version' || arg === '-V') {
|
|
27
|
+
write(`${version()}\n`);
|
|
28
|
+
return EXIT_OK;
|
|
29
|
+
}
|
|
30
|
+
if (arg === undefined || arg.startsWith('-')) {
|
|
31
|
+
write(arg === undefined ? USAGE : `unknown option ${arg}\n${USAGE}`);
|
|
32
|
+
return EXIT_USAGE;
|
|
33
|
+
}
|
|
34
|
+
return arg;
|
|
35
|
+
}
|
|
8
36
|
function refuse(code, message, fix, write) {
|
|
9
37
|
write(`${code}: ${message}\n fix: ${fix}\n`);
|
|
10
38
|
return EXIT_RUNTIME;
|
|
@@ -29,11 +57,9 @@ export async function check(argv, write) {
|
|
|
29
57
|
}
|
|
30
58
|
}
|
|
31
59
|
async function inspect(argv, write) {
|
|
32
|
-
const file = argv[0];
|
|
33
|
-
if (file ===
|
|
34
|
-
|
|
35
|
-
return EXIT_USAGE;
|
|
36
|
-
}
|
|
60
|
+
const file = target(argv[0], write);
|
|
61
|
+
if (typeof file === 'number')
|
|
62
|
+
return file;
|
|
37
63
|
const loaded = (await import(pathToFileURL(resolve(file)).href));
|
|
38
64
|
const plugin = loaded.default ?? loaded;
|
|
39
65
|
for (const registered of [...overrides().keys()])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linegauge",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "A printer's line gauge \u2014 the steel rule marked in picas and points. Measuring, wrapping, truncating and slicing styled terminal text without the edge fraying \u2014 grapheme-correct over Intl.Segmenter. Drop-in paths for string-width, wrap-ansi, strip-ansi and slice-ansi. Zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|