commit-status
Advanced tools
Comparing version 2.0.1 to 4.0.0
#!/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" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
37072
8
80
0
1
71
1
1