all-contributors-cli
Advanced tools
Comparing version 3.0.6 to 3.0.7
15
cli.js
@@ -5,3 +5,2 @@ #!/usr/bin/env node | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
@@ -35,7 +34,6 @@ var yargs = require('yargs'); | ||
try { | ||
return JSON.parse(fs.readFileSync(configPath, 'utf-8')); | ||
return util.configFile.readConfig(configPath); | ||
} catch (error) { | ||
if (configPath !== defaultRCFile) { | ||
console.error(error.message); | ||
process.exit(1); | ||
onError(error); | ||
} | ||
@@ -85,3 +83,4 @@ } | ||
if (error) { | ||
return console.error(error); | ||
console.error(error.message); | ||
process.exit(1); | ||
} | ||
@@ -91,8 +90,2 @@ } | ||
function promptForCommand(argv, cb) { | ||
try { | ||
fs.statSync(argv.config); | ||
} catch (error) { // No config file --> first time using the command | ||
return cb('init'); | ||
} | ||
var questions = [{ | ||
@@ -99,0 +92,0 @@ type: 'list', |
@@ -7,3 +7,10 @@ 'use strict'; | ||
function readConfig(configPath) { | ||
return JSON.parse(fs.readFileSync(configPath, 'utf-8')); | ||
try { | ||
return JSON.parse(fs.readFileSync(configPath, 'utf-8')); | ||
} catch (error) { | ||
if (error.code === 'ENOENT') { | ||
throw new Error('Configuration file not found: ' + configPath); | ||
} | ||
throw error; | ||
} | ||
} | ||
@@ -16,3 +23,8 @@ | ||
function writeContributors(configPath, contributors, cb) { | ||
var config = readConfig(configPath); | ||
var config; | ||
try { | ||
config = readConfig(configPath); | ||
} catch (error) { | ||
return cb(error); | ||
} | ||
var content = _.assign(config, {contributors: contributors}); | ||
@@ -19,0 +31,0 @@ return writeConfig(configPath, content, cb); |
{ | ||
"name": "all-contributors-cli", | ||
"version": "3.0.6", | ||
"version": "3.0.7", | ||
"description": "Tool to easily add recognition for new contributors", | ||
@@ -5,0 +5,0 @@ "bin": { |
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
47923
28
1302
2