linegauge 0.4.4 → 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 CHANGED
@@ -60,7 +60,7 @@ widest(['a', 'bbb', 'cc']); // 3
60
60
  Byte-for-byte call-compatible, so this resolves without a code change:
61
61
 
62
62
  ```json
63
- { "overrides": { "string-width": "npm:linegauge@^0.4" } }
63
+ { "overrides": { "string-width": "npm:linegauge@^0.5" } }
64
64
  ```
65
65
 
66
66
  ## What "without the edge fraying" means
@@ -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: **84,579 bytes** against **170,342** for the incumbents it replaces — a ratio of **0.4965**.
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 === undefined) {
34
- write('usage: linegauge check <plugin-file>\n');
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,12 +1,12 @@
1
1
  {
2
2
  "name": "linegauge",
3
- "version": "0.4.4",
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",
7
7
  "sideEffects": ["./dist/cli.js"],
8
8
  "engines": {
9
- "node": ">=24"
9
+ "node": "^20.19.0 || >=22.13.0"
10
10
  },
11
11
  "exports": {
12
12
  ".": {