@cto.af/linewrap-cli 2.1.0 → 3.0.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/bin/linewrap.js +12 -12
- package/package.json +6 -14
package/bin/linewrap.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {inspect, promisify} from 'util';
|
|
3
|
+
import {inspect, promisify} from 'node:util';
|
|
4
4
|
import {LineWrap} from '@cto.af/linewrap';
|
|
5
|
-
import {fileURLToPath} from 'url';
|
|
6
|
-
import fs from 'fs';
|
|
7
|
-
import os from 'os';
|
|
5
|
+
import {fileURLToPath} from 'node:url';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import os from 'node:os';
|
|
8
8
|
import {parseArgsWithHelp} from 'minus-h';
|
|
9
9
|
|
|
10
|
+
export const DEFAULTS = {
|
|
11
|
+
width: process.stdout.columns ?? 80,
|
|
12
|
+
};
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* @type {Parameters<generateHelp>[0]}
|
|
12
16
|
*/
|
|
@@ -26,11 +30,6 @@ const config = {
|
|
|
26
30
|
argumentName: 'string',
|
|
27
31
|
description: 'What string to use when a word is longer than the max width, and in overflow mode "clip"',
|
|
28
32
|
},
|
|
29
|
-
example7: {
|
|
30
|
-
short: '7',
|
|
31
|
-
type: 'boolean',
|
|
32
|
-
description: 'turn on the extra rules from Example 7 of UAX #14',
|
|
33
|
-
},
|
|
34
33
|
firstCol: {
|
|
35
34
|
short: 'c',
|
|
36
35
|
type: 'string',
|
|
@@ -121,7 +120,7 @@ const config = {
|
|
|
121
120
|
width: {
|
|
122
121
|
short: 'w',
|
|
123
122
|
type: 'string',
|
|
124
|
-
default: String(
|
|
123
|
+
default: String(DEFAULTS.width),
|
|
125
124
|
argumentName: 'columns',
|
|
126
125
|
description: 'maximum line length',
|
|
127
126
|
},
|
|
@@ -177,11 +176,12 @@ export async function main(
|
|
|
177
176
|
options,
|
|
178
177
|
process = {exit, stdin, stdout, stderr}
|
|
179
178
|
) {
|
|
179
|
+
config.options.width.default = String(DEFAULTS.width);
|
|
180
180
|
const {values, positionals} = parseArgsWithHelp({
|
|
181
181
|
...config,
|
|
182
182
|
...extraConfig,
|
|
183
183
|
}, {
|
|
184
|
-
width:
|
|
184
|
+
width: DEFAULTS.width,
|
|
185
185
|
...options,
|
|
186
186
|
});
|
|
187
187
|
|
|
@@ -205,7 +205,6 @@ export async function main(
|
|
|
205
205
|
const opts = {
|
|
206
206
|
escape: values.html ? htmlEscape : s => s,
|
|
207
207
|
ellipsis: values.ellipsis,
|
|
208
|
-
example7: Boolean(values.example7),
|
|
209
208
|
firstCol: parseInt(values.firstCol, 10),
|
|
210
209
|
hyphen: values.hyphen,
|
|
211
210
|
indent: parseInt(values.indent, 10) || values.indent,
|
|
@@ -251,6 +250,7 @@ export async function main(
|
|
|
251
250
|
|
|
252
251
|
if (fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
253
252
|
main().catch(e => {
|
|
253
|
+
// eslint-disable-next-line no-console
|
|
254
254
|
console.error(e);
|
|
255
255
|
process.exit(1);
|
|
256
256
|
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cto.af/linewrap-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Wrap lines using the Unicode Line Breaking algorithm from UAX #14",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"linewrap": "bin/linewrap.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "c8
|
|
10
|
+
"test": "c8 node --test test/*.test.js",
|
|
11
11
|
"lint": "eslint .",
|
|
12
12
|
"build": "npm run lint && npm run test && npm pack --dry-run"
|
|
13
13
|
},
|
|
@@ -26,19 +26,11 @@
|
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"repository": "cto-af/linewrap-cli",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@cto.af/linewrap": "
|
|
30
|
-
"minus-h": "
|
|
29
|
+
"@cto.af/linewrap": "3.0.0",
|
|
30
|
+
"minus-h": "3.0.0"
|
|
31
31
|
},
|
|
32
|
-
"
|
|
33
|
-
"@cto.af/eslint-config": "4.1.5",
|
|
34
|
-
"@types/node": "22.1.0",
|
|
35
|
-
"c8": "10.1.2",
|
|
36
|
-
"eslint": "9.8.0",
|
|
37
|
-
"eslint-plugin-mocha": "10.5.0",
|
|
38
|
-
"mocha": "10.7.0"
|
|
39
|
-
},
|
|
40
|
-
"packageManager": "pnpm@9.7.0",
|
|
32
|
+
"packageManager": "pnpm@10.11.0",
|
|
41
33
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
34
|
+
"node": ">=20"
|
|
43
35
|
}
|
|
44
36
|
}
|