Comparing version 2.2.0 to 2.2.1
@@ -5,26 +5,6 @@ #!/usr/bin/env node | ||
const path = require('path') | ||
const minimist = require('minimist') | ||
const pkg = require('../package.json') | ||
const JSON5 = require('./') | ||
const argv = minimist(process.argv.slice(2), { | ||
alias: { | ||
'convert': 'c', | ||
'space': 's', | ||
'validate': 'v', | ||
'out-file': 'o', | ||
'version': 'V', | ||
'help': 'h', | ||
}, | ||
boolean: [ | ||
'convert', | ||
'validate', | ||
'version', | ||
'help', | ||
], | ||
string: [ | ||
'space', | ||
'out-file', | ||
], | ||
}) | ||
const argv = parseArgs() | ||
@@ -36,3 +16,3 @@ if (argv.version) { | ||
} else { | ||
const inFilename = argv._[0] | ||
const inFilename = argv.defaults[0] | ||
@@ -70,3 +50,3 @@ let readStream | ||
// the same name but with a .json extension will be written. | ||
if (argv.convert && inFilename && !argv.o) { | ||
if (argv.convert && inFilename && !argv.outFile) { | ||
const parsedFilename = path.parse(inFilename) | ||
@@ -81,4 +61,4 @@ const outFilename = path.format( | ||
writeStream = fs.createWriteStream(outFilename) | ||
} else if (argv.o) { | ||
writeStream = fs.createWriteStream(argv.o) | ||
} else if (argv.outFile) { | ||
writeStream = fs.createWriteStream(argv.outFile) | ||
} else { | ||
@@ -97,2 +77,62 @@ writeStream = process.stdout | ||
function parseArgs () { | ||
let convert | ||
let space | ||
let validate | ||
let outFile | ||
let version | ||
let help | ||
const defaults = [] | ||
const args = process.argv.slice(2) | ||
for (let i = 0; i < args.length; i++) { | ||
const arg = args[i] | ||
switch (arg) { | ||
case '--convert': | ||
case '-c': | ||
convert = true | ||
break | ||
case '--space': | ||
case '-s': | ||
space = args[++i] | ||
break | ||
case '--validate': | ||
case '-v': | ||
validate = true | ||
break | ||
case '--out-file': | ||
case '-o': | ||
outFile = args[++i] | ||
break | ||
case '--version': | ||
case '-V': | ||
version = true | ||
break | ||
case '--help': | ||
case '-h': | ||
help = true | ||
break | ||
default: | ||
defaults.push(arg) | ||
break | ||
} | ||
} | ||
return { | ||
convert, | ||
space, | ||
validate, | ||
outFile, | ||
version, | ||
help, | ||
defaults, | ||
} | ||
} | ||
function version () { | ||
@@ -99,0 +139,0 @@ console.log(pkg.version) |
{ | ||
"name": "json5", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "JSON for humans.", | ||
@@ -51,5 +51,2 @@ "main": "lib/index.js", | ||
"homepage": "http://json5.org/", | ||
"dependencies": { | ||
"minimist": "^1.2.5" | ||
}, | ||
"devDependencies": { | ||
@@ -56,0 +53,0 @@ "core-js": "^2.6.5", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
4345
228701
20
- Removedminimist@^1.2.5
- Removedminimist@1.2.8(transitive)