Skip to content

Commit

Permalink
normalise versions for target == this comparison
Browse files Browse the repository at this point in the history
PR-URL: #716
  • Loading branch information
rvagg committed Sep 8, 2015
1 parent 31a2acb commit 846337e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ var semver = require('semver')
// `process.version` and `process.release` where it exists.
function processRelease (argv, gyp, defaultVersion, defaultRelease) {
var version = argv[0] || gyp.opts.target || defaultVersion
, isDefaultVersion = version === defaultVersion
, versionSemver = semver.parse(version)
, overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl
, isDefaultVersion
, isIojs
, name
, distBaseUrl
Expand All @@ -28,6 +28,9 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) {
// flatten version into String
version = versionSemver.version

// defaultVersion should come from process.version so ought to be valid semver
isDefaultVersion = version === semver.parse(defaultVersion).version

// can't use process.release if we're using --target=x.y.z
if (!isDefaultVersion)
defaultRelease = null
Expand Down
53 changes: 53 additions & 0 deletions test/test-process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,56 @@ test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=ht
})
})

test('test process release - process.release ~ node@4.0.0-rc.4', function (t) {
t.plan(2)

var release = processRelease([], { 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'
})
})


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

// note the missing 'v' on the arg, it should normalise when checking
// whether we're on the default or not
var release = processRelease([ '4.0.0-rc.4' ], { 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 846337e

Please sign in to comment.