diff --git a/lib/process-release.js b/lib/process-release.js index b536003cb8..ea7e87e5e2 100644 --- a/lib/process-release.js +++ b/lib/process-release.js @@ -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 diff --git a/test/test-process-release.js b/test/test-process-release.js index c0fbbf624e..bc39aafa7d 100644 --- a/test/test-process-release.js +++ b/test/test-process-release.js @@ -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' + }) +}) +