Socket
Socket
Sign inDemoInstall

all-contributors-cli

Package Overview
Dependencies
126
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-beta8 to 2.0.0-beta9

40

cli.js

@@ -8,2 +8,3 @@ #!/usr/bin/env node

var yargs = require('yargs');
var inquirer = require('inquirer');

@@ -87,10 +88,35 @@ var init = require('./lib/init');

var command = argv._[0];
function promptForCommand(argv, cb) {
try {
fs.statSync(argv.config);
} catch (error) { // No config file --> first time using the command
return cb('init');
}
if (command === 'init') {
init(onError);
} else if (command === 'generate') {
startGeneration(argv, onError);
} else if (command === 'add') {
addContribution(argv, onError);
var questions = [{
type: 'list',
name: 'command',
message: "What do you want to do?",
choices: [{
name: 'Add a new contributor or add a new contribution type',
value: 'add'
}, {
name: 'Re-generate the contributors list',
value: 'generate'
}],
default: 0
}];
inquirer.prompt(questions, function treatAnswers(answers) {
return cb(answers.command);
});
}
promptForCommand(argv, function (command) {
if (command === 'init') {
init(onError);
} else if (command === 'generate') {
startGeneration(argv, onError);
} else if (command === 'add') {
addContribution(argv, onError);
}
});

@@ -40,2 +40,7 @@ 'use strict';

default: 100
}, {
type: 'confirm',
name: 'commit',
message: "Do you want this badge to auto-commit when contributors are added?",
default: true
}];

@@ -61,2 +66,3 @@

imageSize: answers.imageSize,
commit: answers.commit,
contributors: []

@@ -63,0 +69,0 @@ };

14

lib/util/configFile.js

@@ -6,12 +6,2 @@ 'use strict';

function formatCommaFirst(o) {
return JSON.stringify(o, null, 2)
.split(/(,\n\s+)/)
.map(function (e, i) {
return i % 2 ? '\n' + e.substring(4) + ', ' : e;
})
.join('') +
'\n';
}
function readConfig(configPath) {

@@ -22,3 +12,3 @@ return JSON.parse(fs.readFileSync(configPath, 'utf-8'));

function writeConfig(configPath, content, cb) {
return fs.writeFile(configPath, formatCommaFirst(content), cb);
return fs.writeFile(configPath, JSON.stringify(content, null, 2), cb);
}

@@ -29,3 +19,3 @@

var content = _.assign(config, {contributors: contributors});
return fs.writeFile(configPath, formatCommaFirst(content), cb);
return fs.writeFile(configPath, JSON.stringify(content, null, 2), cb);
}

@@ -32,0 +22,0 @@

'use strict';
var path = require('path');
var _ = require('lodash/fp');

@@ -39,3 +40,3 @@

function spawnCommand(args, cb) {
function spawnGitCommand(args, cb) {
var git = spawn('git', args);

@@ -47,3 +48,7 @@ git.stderr.on('data', cb);

function commit(options, data, cb) {
spawnCommand(['add', '.'], function (error) {
var files = options.files.concat(options.config);
var absolutePathFiles = files.map(function (file) {
return path.resolve(process.cwd(), file);
});
spawnGitCommand(['add'].concat(absolutePathFiles), function (error) {
if (error) {

@@ -53,3 +58,3 @@ return cb(error);

var commitMessage = _.template(options.commitTemplate || commitTemplate)(data);
spawnCommand(['commit', '-m', commitMessage], cb);
spawnGitCommand(['commit', '-m', commitMessage], cb);
});

@@ -56,0 +61,0 @@ }

{
"name": "all-contributors-cli",
"version": "2.0.0-beta8",
"version": "2.0.0-beta9",
"description": "Tool to easily add recognition for new contributors",

@@ -5,0 +5,0 @@ "bin": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc