Skip to content

Commit

Permalink
Add --tag-prefix option for github releases (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
reconbot authored and ralphtheninja committed Aug 28, 2018
1 parent 17dd2d3 commit 4c94159
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -35,6 +35,7 @@ prebuild-install [options]
--runtime -r runtime (Node runtime [node or electron] to build or install for, default is node)
--path -p path (make a prebuild-install here)
--token -T gh-token (github token for private repos)
--tag-prefix <prefix> (github tag prefix, default is "v")
--build-from-source (skip prebuild download)
--verbose (log verbosely)
--libc (use provided libc rather than system default)
Expand Down
2 changes: 1 addition & 1 deletion asset.js
Expand Up @@ -28,7 +28,7 @@ function findAssetId (opts, cb) {

// Find asset id in release
for (var release of data) {
if (release.tag_name === 'v' + opts.pkg.version) {
if (release.tag_name === opts['tag-prefix'] + opts.pkg.version) {
for (var asset of release.assets) {
if (asset.browser_download_url === downloadUrl) {
return cb(null, asset.id)
Expand Down
1 change: 1 addition & 0 deletions help.txt
Expand Up @@ -5,6 +5,7 @@ prebuild-install [options]
--runtime -r runtime (Node runtime [node or electron] to build or install for, default is node)
--path -p path (make a prebuild-install here)
--token -T gh-token (github token for private repos)
--tag-prefix <prefix> (github tag prefix, default is "v")
--force (always use prebuilt binaries when available)
--build-from-source (skip prebuild download)
--verbose (log verbosely)
Expand Down
3 changes: 2 additions & 1 deletion rc.js
Expand Up @@ -42,7 +42,8 @@ module.exports = function (pkg) {
path: '.',
proxy: env.npm_config_proxy || env['HTTP_PROXY'],
'https-proxy': env.npm_config_https_proxy || env['HTTPS_PROXY'],
'local-address': env.npm_config_local_address
'local-address': env.npm_config_local_address,
'tag-prefix': 'v'
}, minimist(process.argv, {
alias: {
target: 't',
Expand Down
3 changes: 2 additions & 1 deletion test/asset-test.js
Expand Up @@ -128,6 +128,7 @@ function getOpts () {
platform: process.platform,
arch: process.arch,
path: __dirname,
token: 'TOKEN'
token: 'TOKEN',
'tag-prefix': 'v'
}
}
9 changes: 9 additions & 0 deletions test/rc-test.js
Expand Up @@ -36,6 +36,7 @@ test('custom config and aliases', function (t) {
t.equal(rc.libc, 'testlibc', 'libc family')
t.equal(rc.abi, '50', 'correct ABI')
t.equal(rc.token, 'TOKEN', 'correct token')
t.equal(rc['tag-prefix'], 'v', 'correct default tag prefix')
t.end()
})
})
Expand Down Expand Up @@ -102,6 +103,14 @@ test('use default ABI', function (t) {
})
})

test('using --tag-prefix will set the tag prefix', function (t) {
var args = ['--tag-prefix @scoped/package@']
runRc(t, args.join(' '), {}, function (rc) {
t.equal(rc['tag-prefix'], '@scoped/package@', 'tag prefix should be set')
t.end()
})
})

function runRc (t, args, env, cb) {
var cmd = 'node ' + path.resolve(__dirname, '..', 'rc.js') + ' ' + args
env = Object.assign({}, process.env, env)
Expand Down

0 comments on commit 4c94159

Please sign in to comment.