From 1d3ab82d736317ee9df002a457c95ccd9c2c4a4e Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 19 Aug 2021 20:15:52 +0200 Subject: [PATCH] Require Node.js 12.20 --- .editorconfig | 5 +- .gitattributes | 2 +- .github/workflows/main.yml | 9 +--- .gitignore | 1 + .npmrc | 1 + cli.js | 20 +++---- license | 22 ++------ package.json | 106 ++++++++++++++++++------------------- readme.md | 8 --- test.js | 7 ++- 10 files changed, 77 insertions(+), 104 deletions(-) create mode 100644 .npmrc diff --git a/.editorconfig b/.editorconfig index 8f9d77e..1c6314a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,9 +7,6 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[{package.json,*.yml}] +[*.yml] indent_style = space indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 176a458..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -* text=auto +* 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 38e359a..18ddd49 100755 --- a/cli.js +++ b/cli.js @@ -1,9 +1,9 @@ #!/usr/bin/env node -'use strict'; -const fs = require('fs'); -const getStdin = require('get-stdin'); -const meow = require('meow'); -const fn = require('strip-json-comments'); +import process from 'node:process'; +import fs from 'node:fs'; +import getStdin from 'get-stdin'; +import meow from 'meow'; +import stripJsonComments from 'strip-json-comments'; const cli = meow(` Usage @@ -16,22 +16,24 @@ const cli = meow(` Example $ strip-json-comments input.json > output.json `, { - string: ['_'] + importMeta: import.meta, }); function init(data) { - console.log(fn(data, cli.flags)); + console.log(stripJsonComments(data, cli.flags)); } const input = cli.input[0]; if (!input && process.stdin.isTTY) { - console.error('Filepath required'); + console.error('Specify a file path'); process.exit(1); } if (input) { init(fs.readFileSync(input, 'utf8')); } else { - getStdin().then(init); + (async () => { + init(await getStdin()); + })(); } 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 93d0dee..481fbff 100644 --- a/package.json +++ b/package.json @@ -1,56 +1,54 @@ { - "name": "strip-json-comments-cli", - "version": "1.0.1", - "description": "Strip comments from JSON. Lets you use comments in your JSON files!", - "license": "MIT", - "repository": "sindresorhus/strip-json-comments-cli", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bin": { - "strip-json-comments": "cli.js" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "cli.js" - ], - "keywords": [ - "cli-app", - "cli", - "json", - "strip", - "remove", - "delete", - "trim", - "comments", - "multiline", - "parse", - "config", - "configuration", - "conf", - "settings", - "util", - "env", - "environment" - ], - "dependencies": { - "get-stdin": "^5.0.1", - "meow": "^3.5.0", - "strip-json-comments": "^2.0.0" - }, - "devDependencies": { - "ava": "*", - "pify": "^2.3.0", - "xo": "*" - }, - "xo": { - "esnext": true - } + "name": "strip-json-comments-cli", + "version": "1.0.1", + "description": "Strip comments from JSON. Lets you use comments in your JSON files!", + "license": "MIT", + "repository": "sindresorhus/strip-json-comments-cli", + "funding": "https://github.com/sponsors/sindresorhus", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "https://sindresorhus.com" + }, + "bin": { + "strip-json-comments": "cli.js" + }, + "type": "module", + "exports": "./index.js", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "cli.js" + ], + "keywords": [ + "cli-app", + "cli", + "json", + "strip", + "remove", + "delete", + "trim", + "comments", + "multiline", + "parse", + "config", + "configuration", + "settings", + "util", + "env", + "environment" + ], + "dependencies": { + "get-stdin": "^9.0.0", + "meow": "^10.1.1", + "strip-json-comments": "^4.0.0" + }, + "devDependencies": { + "ava": "^3.15.0", + "xo": "^0.44.0" + } } diff --git a/readme.md b/readme.md index 9835538..6a5e6cb 100644 --- a/readme.md +++ b/readme.md @@ -2,14 +2,12 @@ > Strip comments from JSON. Lets you use comments in your JSON files! - ## Install ``` $ npm install --global strip-json-comments-cli ``` - ## Usage ``` @@ -26,12 +24,6 @@ $ strip-json-comments --help $ strip-json-comments input.json > output.json ``` - ## Related - [strip-json-comments](https://github.com/sindresorhus/strip-json-comments) - API for this module - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/test.js b/test.js index e47df03..eb3ae92 100644 --- a/test.js +++ b/test.js @@ -1,13 +1,12 @@ -import childProcess from 'child_process'; import test from 'ava'; -import pify from 'pify'; +import execa from 'execa'; test('main', async t => { - const stdout = await pify(childProcess.execFile)('./cli.js', ['fixture.json']); + const {stdout} = await execa('./cli.js', ['fixture.json']); t.deepEqual(JSON.parse(stdout), {unicorn: 'cake'}); }); test('stdin', async t => { - const stdout = await pify(childProcess.exec)('echo \'{/*rainbows*/"unicorn":"cake"}\' | ./cli.js'); + const {stdout} = await execa('./cli.js', {input: '{/*rainbows*/"unicorn":"cake"}'}); t.deepEqual(JSON.parse(stdout), {unicorn: 'cake'}); });