Comparing version 1.0.6 to 1.0.7
@@ -8,10 +8,4 @@ #!/usr/bin/env node | ||
HOME_WIN = process.env.HOMEPATH, | ||
HOME_UNIX = process.env.HOME, | ||
HOME = (HOME_UNIX || HOME_WIN) + '/', | ||
check = require('checkup'), | ||
exec = require('execon'), | ||
tryRequire = require('tryrequire'), | ||
@@ -33,7 +27,3 @@ argv = process.argv, | ||
argsEmpty = Object.keys(args).length === 1, | ||
config = tryRequire(HOME + '.github-release') || { | ||
token: args.token | ||
}; | ||
argsEmpty = Object.keys(args).length === 1; | ||
@@ -44,14 +34,8 @@ if (args.version) | ||
help(); | ||
else if (!config.token) | ||
console.error([ | ||
'File ~/.github-release.json with token not found!', | ||
'Please set --token parameter' | ||
].join('\n')); | ||
else | ||
grizzly(config.token); | ||
grizzly(); | ||
function grizzly(token) { | ||
function grizzly() { | ||
var error = exec.try(function() { | ||
check([ | ||
token, | ||
args.repo, | ||
@@ -62,3 +46,2 @@ args.owner, | ||
args.body], [ | ||
'token', | ||
'repo', | ||
@@ -73,3 +56,3 @@ 'owner', | ||
if (!error) | ||
release(token, { | ||
release(args.token, { | ||
repo : args.repo, | ||
@@ -76,0 +59,0 @@ owner : args.owner, |
(function() { | ||
'use strict'; | ||
var GitHubApi = require('github'), | ||
var fs = require('fs'), | ||
exec = require('execon'), | ||
GitHubApi = require('github'), | ||
ERROR_TOKEN = 'File ~/.grizzly.json with token not found!', | ||
github = new GitHubApi({ | ||
@@ -11,16 +15,51 @@ version: '3.0.0' | ||
module.exports = function(token, options, callback) { | ||
github.authenticate({ | ||
type: 'oauth', | ||
token: token | ||
exec.if(token, function() { | ||
release(token, options, callback); | ||
}, function(fn) { | ||
readConfig(function(error, json) { | ||
if (!error) | ||
token = json.token; | ||
fn(); | ||
}); | ||
}); | ||
github.releases.createRelease({ | ||
owner : options.owner, | ||
repo : options.repo, | ||
tag_name : options.tag_name, | ||
name : options.name, | ||
body : options.body | ||
}, callback); | ||
}; | ||
function release(token, options, callback) { | ||
if (!token) | ||
callback(Error(ERROR_TOKEN)); | ||
else { | ||
github.authenticate({ | ||
type: 'oauth', | ||
token: token | ||
}); | ||
github.releases.createRelease({ | ||
owner : options.owner, | ||
repo : options.repo, | ||
tag_name : options.tag_name, | ||
name : options.name, | ||
body : options.body | ||
}, callback); | ||
} | ||
} | ||
function readConfig(callback) { | ||
var HOME_WIN = process.env.HOMEPATH, | ||
HOME_UNIX = process.env.HOME, | ||
HOME = (HOME_UNIX || HOME_WIN) + '/'; | ||
fs.readFile(HOME + '.grizzly.json', 'utf8', function(error, data) { | ||
var json; | ||
if (!error) | ||
error = exec.try(function() { | ||
json = JSON.parse(data); | ||
}); | ||
callback(error, json); | ||
}); | ||
} | ||
})(); |
{ | ||
"name": "grizzly", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "create release on github", | ||
@@ -29,5 +29,4 @@ "main": "lib/release.js", | ||
"github": "~0.2.3", | ||
"minimist": "~1.1.0", | ||
"tryrequire": "~1.1.3" | ||
"minimist": "~1.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
7670
4
134
3
- Removedtryrequire@~1.1.3
- Removedtry-catch@1.0.0(transitive)
- Removedtryrequire@1.1.5(transitive)