Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commit-status

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commit-status - npm Package Compare versions

Comparing version 2.0.1 to 4.0.0

circle.yml

89

commit-status.js
#!/usr/bin/env node
'use strict'
const validate = require('./validate')
const commitStatus = require('./index')
const usage = ' (Usage: commit-status <state> <context> <description> [<target_url>])'
var token = process.env.GH_STATUS_TOKEN || process.env.GH_TOKEN;
var sha = process.env.CIRCLE_SHA1 || process.env.TRAVIS_COMMIT;
var owner = process.env.CIRCLE_PROJECT_USERNAME || extractSlug(process.env.TRAVIS_REPO_SLUG, 0);
var repo = process.env.CIRCLE_PROJECT_REPONAME || extractSlug(process.env.TRAVIS_REPO_SLUG, 1);
var usage = ' (Usage: commit-status <state> <context> <description> [<target_url>])';
validate(
[token, 'GitHub token not configured (use GH_STATUS_TOKEN env var)'],
[sha, 'Unable to detect current build’s SHA'],
[owner, 'Unable to detect repository owner'],
[repo, 'Unable to detect repository name'],
[process.argv.length >= 5, 'Not enough arguments.' + usage],
[process.argv.length <= 6, 'Too many arguments.' + usage]
);
var state = process.argv[2];
var context = process.argv[3];
var description = process.argv[4];
var targetUrl = process.argv[5];
var validStates = ['pending', 'success', 'error', 'failure'];
validate(
[validStates.indexOf(state) >= 0, 'Invalid state (allowed: ' + state + ')']
);
var Octokat = require('octokat');
var octo = new Octokat({ token: token });
octo.repos(owner, repo).statuses(sha).create({
state: state,
context: context,
description: description,
target_url: targetUrl || undefined,
}).catch(function (e) {
setImmediate(function () {
throw e;
});
});
function extractSlug (str, i) {
return str && str.split('/')[i];
try {
validate(
[process.argv.length >= 5, 'Not enough arguments.' + usage],
[process.argv.length <= 6, 'Too many arguments.' + usage]
)
commitStatus.post({
state: process.argv[2],
context: process.argv[3],
description: process.argv[4],
url: process.argv[5]
}).catch(function (e) {
setImmediate(function () {
throw e
})
})
} catch (e) {
console.error(e.message)
process.exit(1)
}
function validate () {
var problems = [ ];
for (var i = 0; i < arguments.length; i++) {
if (!arguments[i][0]) {
problems.push(arguments[i][1]);
}
}
if (problems.length) {
console.error('Unable to run:');
problems.forEach(function (problem) {
console.error(' -', problem);
});
console.error('');
process.exit(1);
}
}
{
"name": "commit-status",
"version": "2.0.1",
"version": "4.0.0",
"description": "Simple command-line application to post commit status to GitHub (for use in CI)",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "./commit-status.js success meow '^_^;'"
},

@@ -24,3 +24,6 @@ "bin": {

"octokat": "^0.4.11"
},
"devDependencies": {
"standard": "^8.6.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc