Skip to content

Commit

Permalink
Require Node.js 12.20
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 19, 2021
1 parent 255aba9 commit 1d3ab82
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 104 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* text=auto
* text=auto eol=lf
9 changes: 2 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
20 changes: 11 additions & 9 deletions cli.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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());
})();
}
22 changes: 5 additions & 17 deletions license
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.
106 changes: 52 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
8 changes: 0 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand All @@ -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)
7 changes: 3 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
@@ -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'});
});

0 comments on commit 1d3ab82

Please sign in to comment.