From 2c6ddda2f245cf8d56441e8d593071e89be80000 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 13 Jan 2017 20:41:04 +0700 Subject: [PATCH 1/4] Forgot to update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e526ffa..97519af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,3 @@ language: node_js node_js: - '6' - '4' - - '0.12' - - '0.10' From 8e78d928aae50db4980cf8498752abe3e140518f Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Fri, 1 Jan 2021 10:55:05 +1300 Subject: [PATCH 2/4] Move to GitHub Actions (#1) --- .github/workflows/main.yml | 25 +++++++++++++++++++++++++ .travis.yml | 4 ---- readme.md | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..5dbaa22 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,25 @@ +name: CI +on: + - push + - pull_request +jobs: + test: + name: Node.js ${{ matrix.node-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: + - 14 + - 12 + - 10 + - 8 + - 6 + - 4 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 97519af..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - '6' - - '4' diff --git a/readme.md b/readme.md index 011c5ba..6e9b21a 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# string-width-cli [![Build Status](https://travis-ci.org/sindresorhus/string-width-cli.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width-cli) +# string-width-cli > Get the visual width of a string - the number of columns required to display it From d4fab820f3429436b0cc674074157cacf2ce53ae Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 21 Aug 2021 11:03:44 +0200 Subject: [PATCH 3/4] Require Node.js 12.20 --- .editorconfig | 2 +- .gitattributes | 3 +- .github/workflows/main.yml | 9 +-- .gitignore | 1 + .npmrc | 1 + cli.js | 9 +-- license | 22 ++----- package.json | 117 +++++++++++++++++++------------------ readme.md | 8 --- test.js | 4 +- 10 files changed, 77 insertions(+), 99 deletions(-) create mode 100644 .npmrc diff --git a/.editorconfig b/.editorconfig index 98a761d..1c6314a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,6 +7,6 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[{package.json,*.yml}] +[*.yml] indent_style = space indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5dbaa22..441975c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,15 +10,10 @@ jobs: fail-fast: false matrix: node-version: - - 14 - - 12 - - 10 - - 8 - - 6 - - 4 + - 16 steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/.gitignore b/.gitignore index 3c3629e..239ecff 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +yarn.lock diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/cli.js b/cli.js index d101e7b..6bb1dea 100755 --- a/cli.js +++ b/cli.js @@ -1,7 +1,6 @@ #!/usr/bin/env node -'use strict'; -const meow = require('meow'); -const stringWidth = require('string-width'); +import meow from 'meow'; +import stringWidth from 'string-width'; const cli = meow(` Usage @@ -10,6 +9,8 @@ const cli = meow(` Example $ string-width a古 3 -`); +`, { + importMeta: import.meta, +}); console.log(stringWidth(cli.input[0])); diff --git a/license b/license index 654d0bf..fa7ceba 100644 --- a/license +++ b/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/package.json b/package.json index d769f57..0bc4e58 100644 --- a/package.json +++ b/package.json @@ -1,60 +1,61 @@ { - "name": "string-width-cli", - "version": "2.0.0", - "description": "Get the visual width of a string - the number of columns required to display it", - "license": "MIT", - "repository": "sindresorhus/string-width-cli", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bin": { - "string-width": "cli.js" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "cli.js" - ], - "keywords": [ - "cli-app", - "cli", - "string", - "str", - "character", - "char", - "unicode", - "width", - "visual", - "column", - "columns", - "fullwidth", - "full-width", - "full", - "ansi", - "escape", - "codes", - "command-line", - "terminal", - "console", - "cjk", - "chinese", - "japanese", - "korean", - "fixed-width" - ], - "dependencies": { - "meow": "^3.7.0", - "string-width": "^2.0.0" - }, - "devDependencies": { - "ava": "*", - "execa": "^0.6.0", - "xo": "*" - } + "name": "string-width-cli", + "version": "2.0.0", + "description": "Get the visual width of a string - the number of columns required to display it", + "license": "MIT", + "repository": "sindresorhus/string-width-cli", + "funding": "https://github.com/sponsors/sindresorhus", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "https://sindresorhus.com" + }, + "type": "module", + "bin": { + "string-width": "./cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "cli.js" + ], + "keywords": [ + "cli-app", + "cli", + "string", + "character", + "char", + "unicode", + "width", + "visual", + "column", + "columns", + "fullwidth", + "full-width", + "full", + "ansi", + "escape", + "codes", + "command-line", + "terminal", + "console", + "cjk", + "chinese", + "japanese", + "korean", + "fixed-width" + ], + "dependencies": { + "meow": "^10.1.1", + "string-width": "^5.0.0" + }, + "devDependencies": { + "ava": "^3.15.0", + "execa": "^5.1.1", + "xo": "^0.44.0" + } } diff --git a/readme.md b/readme.md index 6e9b21a..ece0349 100644 --- a/readme.md +++ b/readme.md @@ -6,14 +6,12 @@ Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_ Useful to be able to measure the actual width of command-line output. - ## Install ``` $ npm install --global string-width-cli ``` - ## Usage ``` @@ -27,12 +25,6 @@ $ string-width --help 3 ``` - ## Related - [string-width](https://github.com/sindresorhus/string-width) - API for this module - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/test.js b/test.js index ad6b313..473dea4 100644 --- a/test.js +++ b/test.js @@ -1,7 +1,7 @@ import test from 'ava'; import execa from 'execa'; -test(async t => { +test('main', async t => { const {stdout} = await execa('./cli.js', ['a古']); - t.is(parseInt(stdout, 10), 3); + t.is(Number.parseInt(stdout, 10), 3); }); From 73ad3358b5c74c2ded922d90cbbaf13470c3576f Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 21 Aug 2021 11:04:13 +0200 Subject: [PATCH 4/4] 3.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0bc4e58..5fefd4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "string-width-cli", - "version": "2.0.0", + "version": "3.0.0", "description": "Get the visual width of a string - the number of columns required to display it", "license": "MIT", "repository": "sindresorhus/string-width-cli",