diff --git a/README.md b/README.md index 13671a1..487b783 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,6 @@ Options: will be inserted before each line Default: " " --indentEmpty if the input string is empty, should we still indent? Default: false - --isNewline a regular expression to replace newlines in the - input. Empty to leave newlines in place. - Default: "[^\\S\\r\\n\\v\\f\\x85\\u2028\ - \u2029]*[\\r\\n\\v\\f\\x85\\u2028\\u2029]+\\s*" -l,--locale locale for grapheme segmentation. Has very little effect at the moment --newline how to separate the lines of output Default: diff --git a/bin/linewrap.js b/bin/linewrap.js index 66d1ae7..47d74e7 100755 --- a/bin/linewrap.js +++ b/bin/linewrap.js @@ -61,12 +61,6 @@ const config = { default: LineWrap.DEFAULT_OPTIONS.indentEmpty, description: 'if the input string is empty, should we still indent?', }, - isNewline: { - type: 'string', - default: LineWrap.DEFAULT_OPTIONS.isNewline.source, - argumentName: 'regex', - description: 'a regular expression to replace newlines in the input. Empty to leave newlines in place.', - }, locale: { short: 'l', type: 'string', @@ -219,11 +213,7 @@ export async function main( verbose: values.verbose, width: parseInt(values.width, 10), }; - if (typeof values.isNewline === 'string') { - opts.isNewline = (values.isNewline.length === 0) ? - null : - new RegExp(values.isNewline, 'gu'); - } + if (values.verbose) { process.stdout.write(inspect(opts)); } diff --git a/package.json b/package.json index 34ae90e..844c2f9 100644 --- a/package.json +++ b/package.json @@ -26,17 +26,17 @@ "license": "MIT", "repository": "cto-af/linewrap-cli", "dependencies": { - "@cto.af/linewrap": "3.0.0", + "@cto.af/linewrap": "3.2.0", "minus-h": "3.0.0" }, "devDependencies": { - "@cto.af/eslint-config": "6.0.4", - "@types/node": "22.15.29", + "@cto.af/eslint-config": "6.0.5", + "@types/node": "22.15.30", "c8": "10.1.3", "eslint": "9.28.0", "eslint-plugin-mocha": "11.1.0" }, - "packageManager": "pnpm@10.11.0", + "packageManager": "pnpm@10.12.1", "engines": { "node": ">=20" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b555bcc..e50bf27 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,18 +9,18 @@ importers: .: dependencies: '@cto.af/linewrap': - specifier: 3.0.0 - version: 3.0.0 + specifier: 3.2.0 + version: 3.2.0 minus-h: specifier: 3.0.0 version: 3.0.0 devDependencies: '@cto.af/eslint-config': - specifier: 6.0.4 - version: 6.0.4(eslint@9.28.0)(typescript@5.8.3) + specifier: 6.0.5 + version: 6.0.5(eslint@9.28.0)(typescript@5.8.3) '@types/node': - specifier: 22.15.29 - version: 22.15.29 + specifier: 22.15.30 + version: 22.15.30 c8: specifier: 10.1.3 version: 10.1.3 @@ -37,8 +37,8 @@ packages: resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} engines: {node: '>=18'} - '@cto.af/eslint-config@6.0.4': - resolution: {integrity: sha512-cK5Ao2dcB+8zED69uZxmNOEuGfXUHzJTXkLgb1FXN7fQeq9opXiizMg9AuH5CYCaxMZEL0PGI16MSkBjQU1Opw==} + '@cto.af/eslint-config@6.0.5': + resolution: {integrity: sha512-6iXp94N7LgFXqWgLk3u+PnhF7h4PYKNRcEnlQDA4qpFIuxee02dgPg69SBX1GlbftVeUTGM8DPT/xMp7cHZkQw==} engines: {node: '>=20'} '@cto.af/linebreak@3.0.0': @@ -49,6 +49,10 @@ packages: resolution: {integrity: sha512-galJ5m5asgzunHsKxuxRfupMOSoIRAz0+PHwKrZuP5DFOeUaxzX4daOg2ez1Jd/98mVFVYB77tzRaKaD44zEBQ==} engines: {node: '>=20'} + '@cto.af/linewrap@3.2.0': + resolution: {integrity: sha512-2tJBxTMzw4fEUFHXPVrdxVur/wXb30/pJHsMmbXVCbGm0LP7cqK/wJ48JFM2k9pAQqb8UVosFVklCZUHo4dGQg==} + engines: {node: '>=20.13'} + '@cto.af/string-width@4.0.1': resolution: {integrity: sha512-AcDSGja8Vj5/XlBO5cOLxziHestCb4wyAnkDZ+nJA5uVUjoEQgcbALdznU8OwviTw38gbwGWt3EItSUb947eJw==} engines: {node: '>= 20'} @@ -175,8 +179,8 @@ packages: peerDependencies: eslint: '>=9.0.0' - '@types/estree@1.0.7': - resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==} + '@types/estree@1.0.8': + resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} '@types/istanbul-lib-coverage@2.0.6': resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} @@ -184,42 +188,44 @@ packages: '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - '@types/node@22.15.29': - resolution: {integrity: sha512-LNdjOkUDlU1RZb8e1kOIUpN1qQUlzGkEtbVNo53vbrwDg5om6oduhm4SiUaPW5ASTXhAiP0jInWG8Qx9fVlOeQ==} + '@types/node@22.15.30': + resolution: {integrity: sha512-6Q7lr06bEHdlfplU6YRbgG1SFBdlsfNC4/lX+SkhiTs0cpJkOElmWls8PxDFv4yY/xKb8Y6SO0OmSX4wgqTZbA==} - '@typescript-eslint/project-service@8.33.0': - resolution: {integrity: sha512-d1hz0u9l6N+u/gcrk6s6gYdl7/+pp8yHheRTqP6X5hVDKALEaTn8WfGiit7G511yueBEL3OpOEpD+3/MBdoN+A==} + '@typescript-eslint/project-service@8.33.1': + resolution: {integrity: sha512-DZR0efeNklDIHHGRpMpR5gJITQpu6tLr9lDJnKdONTC7vvzOlLAG/wcfxcdxEWrbiZApcoBCzXqU/Z458Za5Iw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/scope-manager@8.33.0': - resolution: {integrity: sha512-LMi/oqrzpqxyO72ltP+dBSP6V0xiUb4saY7WLtxSfiNEBI8m321LLVFU9/QDJxjDQG9/tjSqKz/E3380TEqSTw==} + '@typescript-eslint/scope-manager@8.33.1': + resolution: {integrity: sha512-dM4UBtgmzHR9bS0Rv09JST0RcHYearoEoo3pG5B6GoTR9XcyeqX87FEhPo+5kTvVfKCvfHaHrcgeJQc6mrDKrA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/tsconfig-utils@8.33.0': - resolution: {integrity: sha512-sTkETlbqhEoiFmGr1gsdq5HyVbSOF0145SYDJ/EQmXHtKViCaGvnyLqWFFHtEXoS0J1yU8Wyou2UGmgW88fEug==} + '@typescript-eslint/tsconfig-utils@8.33.1': + resolution: {integrity: sha512-STAQsGYbHCF0/e+ShUQ4EatXQ7ceh3fBCXkNU7/MZVKulrlq1usH7t2FhxvCpuCi5O5oi1vmVaAjrGeL71OK1g==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/types@8.33.0': - resolution: {integrity: sha512-DKuXOKpM5IDT1FA2g9x9x1Ug81YuKrzf4mYX8FAVSNu5Wo/LELHWQyM1pQaDkI42bX15PWl0vNPt1uGiIFUOpg==} + '@typescript-eslint/types@8.33.1': + resolution: {integrity: sha512-xid1WfizGhy/TKMTwhtVOgalHwPtV8T32MS9MaH50Cwvz6x6YqRIPdD2WvW0XaqOzTV9p5xdLY0h/ZusU5Lokg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.33.0': - resolution: {integrity: sha512-vegY4FQoB6jL97Tu/lWRsAiUUp8qJTqzAmENH2k59SJhw0Th1oszb9Idq/FyyONLuNqT1OADJPXfyUNOR8SzAQ==} + '@typescript-eslint/typescript-estree@8.33.1': + resolution: {integrity: sha512-+s9LYcT8LWjdYWu7IWs7FvUxpQ/DGkdjZeE/GGulHvv8rvYwQvVaUZ6DE+j5x/prADUgSbbCWZ2nPI3usuVeOA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/utils@8.33.0': - resolution: {integrity: sha512-lPFuQaLA9aSNa7D5u2EpRiqdAUhzShwGg/nhpBlc4GR6kcTABttCuyjFs8BcEZ8VWrjCBof/bePhP3Q3fS+Yrw==} + '@typescript-eslint/utils@8.33.1': + resolution: {integrity: sha512-52HaBiEQUaRYqAXpfzWSR2U3gxk92Kw006+xZpElaPMg3C4PgM+A5LqwoQI1f9E5aZ/qlxAZxzm42WX+vn92SQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/visitor-keys@8.33.0': - resolution: {integrity: sha512-7RW7CMYoskiz5OOGAWjJFxgb7c5UNjTG292gYhWeOAcFmYCtVCSqjqSBj5zMhxbXo2JOW95YYrUWJfU0zrpaGQ==} + '@typescript-eslint/visitor-keys@8.33.1': + resolution: {integrity: sha512-3i8NrFcZeeDHJ+7ZUuDkGT+UHq+XoFGsymNK2jZCOHcfEzRQ0BdpRtdpSx/Iyf3MHLWIcLS0COuOPibKQboIiQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} acorn-jsx@5.3.2: @@ -227,8 +233,8 @@ packages: peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 - acorn@8.14.1: - resolution: {integrity: sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==} + acorn@8.15.0: + resolution: {integrity: sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==} engines: {node: '>=0.4.0'} hasBin: true @@ -810,7 +816,7 @@ snapshots: '@bcoe/v8-coverage@1.0.2': {} - '@cto.af/eslint-config@6.0.4(eslint@9.28.0)(typescript@5.8.3)': + '@cto.af/eslint-config@6.0.5(eslint@9.28.0)(typescript@5.8.3)': dependencies: '@eslint/json': 0.12.0 '@stylistic/eslint-plugin': 4.4.0(eslint@9.28.0)(typescript@5.8.3) @@ -831,6 +837,11 @@ snapshots: '@cto.af/linebreak': 3.0.0 '@cto.af/string-width': 4.0.1 + '@cto.af/linewrap@3.2.0': + dependencies: + '@cto.af/linebreak': 3.0.0 + '@cto.af/string-width': 4.0.1 + '@cto.af/string-width@4.0.1': dependencies: '@cto.af/unicode-trie-runtime': 3.2.3 @@ -957,7 +968,7 @@ snapshots: '@stylistic/eslint-plugin@4.4.0(eslint@9.28.0)(typescript@5.8.3)': dependencies: - '@typescript-eslint/utils': 8.33.0(eslint@9.28.0)(typescript@5.8.3) + '@typescript-eslint/utils': 8.33.1(eslint@9.28.0)(typescript@5.8.3) eslint: 9.28.0 eslint-visitor-keys: 4.2.0 espree: 10.3.0 @@ -967,42 +978,42 @@ snapshots: - supports-color - typescript - '@types/estree@1.0.7': {} + '@types/estree@1.0.8': {} '@types/istanbul-lib-coverage@2.0.6': {} '@types/json-schema@7.0.15': {} - '@types/node@22.15.29': + '@types/node@22.15.30': dependencies: undici-types: 6.21.0 - '@typescript-eslint/project-service@8.33.0(typescript@5.8.3)': + '@typescript-eslint/project-service@8.33.1(typescript@5.8.3)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.33.0(typescript@5.8.3) - '@typescript-eslint/types': 8.33.0 + '@typescript-eslint/tsconfig-utils': 8.33.1(typescript@5.8.3) + '@typescript-eslint/types': 8.33.1 debug: 4.4.1 + typescript: 5.8.3 transitivePeerDependencies: - supports-color - - typescript - '@typescript-eslint/scope-manager@8.33.0': + '@typescript-eslint/scope-manager@8.33.1': dependencies: - '@typescript-eslint/types': 8.33.0 - '@typescript-eslint/visitor-keys': 8.33.0 + '@typescript-eslint/types': 8.33.1 + '@typescript-eslint/visitor-keys': 8.33.1 - '@typescript-eslint/tsconfig-utils@8.33.0(typescript@5.8.3)': + '@typescript-eslint/tsconfig-utils@8.33.1(typescript@5.8.3)': dependencies: typescript: 5.8.3 - '@typescript-eslint/types@8.33.0': {} + '@typescript-eslint/types@8.33.1': {} - '@typescript-eslint/typescript-estree@8.33.0(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@8.33.1(typescript@5.8.3)': dependencies: - '@typescript-eslint/project-service': 8.33.0(typescript@5.8.3) - '@typescript-eslint/tsconfig-utils': 8.33.0(typescript@5.8.3) - '@typescript-eslint/types': 8.33.0 - '@typescript-eslint/visitor-keys': 8.33.0 + '@typescript-eslint/project-service': 8.33.1(typescript@5.8.3) + '@typescript-eslint/tsconfig-utils': 8.33.1(typescript@5.8.3) + '@typescript-eslint/types': 8.33.1 + '@typescript-eslint/visitor-keys': 8.33.1 debug: 4.4.1 fast-glob: 3.3.3 is-glob: 4.0.3 @@ -1013,27 +1024,27 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.33.0(eslint@9.28.0)(typescript@5.8.3)': + '@typescript-eslint/utils@8.33.1(eslint@9.28.0)(typescript@5.8.3)': dependencies: '@eslint-community/eslint-utils': 4.7.0(eslint@9.28.0) - '@typescript-eslint/scope-manager': 8.33.0 - '@typescript-eslint/types': 8.33.0 - '@typescript-eslint/typescript-estree': 8.33.0(typescript@5.8.3) + '@typescript-eslint/scope-manager': 8.33.1 + '@typescript-eslint/types': 8.33.1 + '@typescript-eslint/typescript-estree': 8.33.1(typescript@5.8.3) eslint: 9.28.0 typescript: 5.8.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/visitor-keys@8.33.0': + '@typescript-eslint/visitor-keys@8.33.1': dependencies: - '@typescript-eslint/types': 8.33.0 + '@typescript-eslint/types': 8.33.1 eslint-visitor-keys: 4.2.0 - acorn-jsx@5.3.2(acorn@8.14.1): + acorn-jsx@5.3.2(acorn@8.15.0): dependencies: - acorn: 8.14.1 + acorn: 8.15.0 - acorn@8.14.1: {} + acorn@8.15.0: {} ajv@6.12.6: dependencies: @@ -1192,7 +1203,7 @@ snapshots: '@humanfs/node': 0.16.6 '@humanwhocodes/module-importer': 1.0.1 '@humanwhocodes/retry': 0.4.3 - '@types/estree': 1.0.7 + '@types/estree': 1.0.8 '@types/json-schema': 7.0.15 ajv: 6.12.6 chalk: 4.1.2 @@ -1221,8 +1232,8 @@ snapshots: espree@10.3.0: dependencies: - acorn: 8.14.1 - acorn-jsx: 5.3.2(acorn@8.14.1) + acorn: 8.15.0 + acorn-jsx: 5.3.2(acorn@8.15.0) eslint-visitor-keys: 4.2.0 esquery@1.6.0: diff --git a/test/bin.test.js b/test/bin.test.js index 0174f53..ac7eec4 100644 --- a/test/bin.test.js +++ b/test/bin.test.js @@ -47,10 +47,6 @@ const HELP = [ ' will be inserted before each line Default: " "', ' --indentEmpty if the input string is empty, should we still', ' indent? Default: false', - ' --isNewline a regular expression to replace newlines in the', - ' input. Empty to leave newlines in place.', - ' Default: "[^\\\\S\\\\r\\\\n\\\\v\\\\f\\\\x85\\\\u2028\\', - ' \\u2029]*[\\\\r\\\\n\\\\v\\\\f\\\\x85\\\\u2028\\\\u2029]+\\\\s*"', ' -l,--locale locale for grapheme segmentation. Has very', ' little effect at the moment', ' --newline how to separate the lines of output Default:', @@ -192,18 +188,6 @@ test('cli', async t => { ); assert.equal(res.stdout, ' \n'); - // --isNewline - // --newlineReplacement - res = await exec( - {main, stdin: 'foobar'}, '--isNewline', 'o+', '--newlineReplacement', ' 99 ', '-w', '1' - ); - assert.equal(res.stdout, 'f\n99\nbar\n'); - - res = await exec( - {main, stdin: 'foo\nbar'}, '--isNewline', '' - ); - assert.equal(res.stdout, 'foo\nbar\n'); - // --locale // After reading UAX #29 again, I still don't think this changes // anything visible.