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-beta7 to 2.0.0-beta8

21

cli.js

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

var generate = require('./lib/generate');
var markdown = require('./lib/util').markdown;
var util = require('./lib/util');
var updateContributors = require('./lib/contributors');

@@ -27,2 +27,3 @@

.usage('Usage: $0 init')
.boolean('commit')
.default('files', ['README.md'])

@@ -50,3 +51,3 @@ .default('contributorsPerLine', 7)

.forEach(function (file) {
markdown.read(file, function (error, fileContent) {
util.markdown.read(file, function (error, fileContent) {
if (error) {

@@ -56,3 +57,3 @@ return cb(error);

var newFileContent = generate(argv, argv.contributors, fileContent);
markdown.write(file, newFileContent, cb);
util.markdown.write(file, newFileContent, cb);
});

@@ -66,8 +67,16 @@ });

// Add or update contributor in the config file
updateContributors(argv, username, contributions, function (error, contributors) {
updateContributors(argv, username, contributions, function (error, data) {
if (error) {
return onError(error);
}
argv.contributors = contributors;
startGeneration(argv, cb);
argv.contributors = data.contributors;
startGeneration(argv, function (error) {
if (error) {
return cb(error);
}
if (!argv.commit) {
return cb();
}
return util.git.commit(argv, data, cb);
});
});

@@ -74,0 +83,0 @@ }

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

@@ -8,2 +9,6 @@ var add = require('./add');

function isNewContributor(contributorList, username) {
return !_.find({login: username}, contributorList);
}
module.exports = function addContributor(options, username, contributions, cb) {

@@ -16,3 +21,8 @@ prompt(options, username, contributions, function (answers) {

util.configFile.writeContributors(options.config, contributors, function (error) {
return cb(error, contributors);
return cb(error, {
username: answers.username,
contributions: answers.contributions,
contributors: contributors,
newContributor: isNewContributor(options.contributors, answers.username)
});
});

@@ -19,0 +29,0 @@ });

@@ -5,3 +5,3 @@ 'use strict';

var inquirer = require('inquirer');
var getRepoInfo = require('../util').git;
var git = require('../util').git;

@@ -49,3 +49,3 @@ var questions = [{

module.exports = function prompt(cb) {
getRepoInfo(function (error, repoInfo) {
git.getRepoInfo(function (error, repoInfo) {
if (error) {

@@ -52,0 +52,0 @@ return cb(error);

'use strict';
var _ = require('lodash/fp');
var commitTemplate = '<%= (newContributor ? "Add" : "Update") %> <%= username %> as a contributor';
var spawn = require('child_process').spawn;

@@ -26,3 +30,3 @@

module.exports = function getRepoInfo(cb) {
function getRepoInfo(cb) {
getRemoteOriginData(function (error, originUrl) {

@@ -34,2 +38,23 @@ if (error) {

});
}
function spawnCommand(args, cb) {
var git = spawn('git', args);
git.stderr.on('data', cb);
git.on('close', cb);
}
function commit(options, data, cb) {
spawnCommand(['add', '.'], function (error) {
if (error) {
return cb(error);
}
var commitMessage = _.template(options.commitTemplate || commitTemplate)(data);
spawnCommand(['commit', '-m', commitMessage], cb);
});
}
module.exports = {
commit: commit,
getRepoInfo: getRepoInfo
};
{
"name": "all-contributors-cli",
"version": "2.0.0-beta7",
"version": "2.0.0-beta8",
"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