Skip to content

Commit

Permalink
add back support for passing additional cmdline args
Browse files Browse the repository at this point in the history
PR-URL: #723
  • Loading branch information
rvagg committed Sep 12, 2015
1 parent ff82f2f commit 6e8c3bf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var semver = require('semver')
// file names. Inputs come from command-line switches (--target, --dist-url),
// `process.version` and `process.release` where it exists.
function processRelease (argv, gyp, defaultVersion, defaultRelease) {
var version = argv[0] || gyp.opts.target || defaultVersion
var version = (semver.valid(argv[0]) && argv[0]) || gyp.opts.target || defaultVersion
, versionSemver = semver.parse(version)
, overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl
, isDefaultVersion
Expand Down
28 changes: 28 additions & 0 deletions test/test-process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,31 @@ test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]
})
})


test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string passed as argv[0]', function (t) {
t.plan(2)

// additional arguments can be passed in on the commandline that should be ignored if they
// are not specifying a valid version @ position 0
var release = processRelease([ 'this is no version!' ], { opts: {} }, 'v4.0.0-rc.4', {
name: 'node',
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz'
})

t.equal(release.semver.version, '4.0.0-rc.4')
delete release.semver

t.deepEqual(release, {
version: '4.0.0-rc.4',
name: 'node',
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/',
tarballUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt',
versionDir: '4.0.0-rc.4',
libUrl32: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib',
libUrl64: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib',
libPath32: 'win-x86/node.lib',
libPath64: 'win-x64/node.lib'
})
})

0 comments on commit 6e8c3bf

Please sign in to comment.