Skip to content

Commit

Permalink
Download headers tarball for ~0.12.10 || ~0.10.42
Browse files Browse the repository at this point in the history
Properly created -headers.tar.gz files were not available until
v0.12.10 and v0.10.42 (in addition to >= 3).

PR-URL: #877
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
  • Loading branch information
rvagg committed Feb 15, 2016
1 parent 6e28ad1 commit d1e4cc4
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 11 deletions.
6 changes: 5 additions & 1 deletion lib/process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ var semver = require('semver')
, url = require('url')
, path = require('path')

// versions where -headers.tar.gz started shipping
, headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42'
, bitsre = /\/win-(x86|x64)\//
, bitsreV3 = /\/win-(x86|ia32|x64)\// // io.js v3.x.x shipped with "ia32" but should
// have been "x86"
Expand All @@ -21,6 +23,7 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) {
, libUrl32
, libUrl64
, tarballUrl
, canGetHeaders

if (!versionSemver) {
// not a valid semver string, nothing we can do
Expand Down Expand Up @@ -93,7 +96,8 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) {
// making the bold assumption that anything with a version number >3.0.0 will
// have a *-headers.tar.gz file in its dist location, even some frankenstein
// custom version
tarballUrl = url.resolve(baseUrl, name + '-v' + version + (versionSemver.major >= 3 ? '-headers' : '') + '.tar.gz')
canGetHeaders = semver.satisfies(versionSemver, headersTarballRange)
tarballUrl = url.resolve(baseUrl, name + '-v' + version + (canGetHeaders ? '-headers' : '') + '.tar.gz')

return {
version: version,
Expand Down
90 changes: 80 additions & 10 deletions test/test-process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,93 @@ test('test process release - process.version = 0.10.21', function (t) {
})
})

test('test process release - process.version = 0.12.22', function (t) {
// prior to -headers.tar.gz
test('test process release - process.version = 0.12.9', function (t) {
t.plan(2)

var release = processRelease([], { opts: {} }, 'v0.12.22', null)
var release = processRelease([], { opts: {} }, 'v0.12.9', null)

t.equal(release.semver.version, '0.12.22')
t.equal(release.semver.version, '0.12.9')
delete release.semver

t.deepEqual(release, {
version: '0.12.22',
version: '0.12.9',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.12.22/',
tarballUrl: 'https://nodejs.org/dist/v0.12.22/node-v0.12.22.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.12.22/SHASUMS256.txt',
versionDir: '0.12.22',
libUrl32: 'https://nodejs.org/dist/v0.12.22/node.lib',
libUrl64: 'https://nodejs.org/dist/v0.12.22/x64/node.lib',
baseUrl: 'https://nodejs.org/dist/v0.12.9/',
tarballUrl: 'https://nodejs.org/dist/v0.12.9/node-v0.12.9.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.12.9/SHASUMS256.txt',
versionDir: '0.12.9',
libUrl32: 'https://nodejs.org/dist/v0.12.9/node.lib',
libUrl64: 'https://nodejs.org/dist/v0.12.9/x64/node.lib',
libPath32: 'node.lib',
libPath64: 'x64/node.lib'
})
})

// prior to -headers.tar.gz
test('test process release - process.version = 0.10.41', function (t) {
t.plan(2)

var release = processRelease([], { opts: {} }, 'v0.10.41', null)

t.equal(release.semver.version, '0.10.41')
delete release.semver

t.deepEqual(release, {
version: '0.10.41',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.41/',
tarballUrl: 'https://nodejs.org/dist/v0.10.41/node-v0.10.41.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.10.41/SHASUMS256.txt',
versionDir: '0.10.41',
libUrl32: 'https://nodejs.org/dist/v0.10.41/node.lib',
libUrl64: 'https://nodejs.org/dist/v0.10.41/x64/node.lib',
libPath32: 'node.lib',
libPath64: 'x64/node.lib'
})
})

// has -headers.tar.gz
test('test process release - process.release ~ [email protected]', function (t) {
t.plan(2)

var release = processRelease([], { opts: {} }, 'v0.10.42', null)

t.equal(release.semver.version, '0.10.42')
delete release.semver

t.deepEqual(release, {
version: '0.10.42',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.42/',
tarballUrl: 'https://nodejs.org/dist/v0.10.42/node-v0.10.42-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.10.42/SHASUMS256.txt',
versionDir: '0.10.42',
libUrl32: 'https://nodejs.org/dist/v0.10.42/node.lib',
libUrl64: 'https://nodejs.org/dist/v0.10.42/x64/node.lib',
libPath32: 'node.lib',
libPath64: 'x64/node.lib'
})
})

// has -headers.tar.gz
test('test process release - process.release ~ [email protected]', function (t) {
t.plan(2)

var release = processRelease([], { opts: {} }, 'v0.12.10', null)

t.equal(release.semver.version, '0.12.10')
delete release.semver

t.deepEqual(release, {
version: '0.12.10',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.12.10/',
tarballUrl: 'https://nodejs.org/dist/v0.12.10/node-v0.12.10-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.12.10/SHASUMS256.txt',
versionDir: '0.12.10',
libUrl32: 'https://nodejs.org/dist/v0.12.10/node.lib',
libUrl64: 'https://nodejs.org/dist/v0.12.10/x64/node.lib',
libPath32: 'node.lib',
libPath64: 'x64/node.lib'
})
Expand Down

0 comments on commit d1e4cc4

Please sign in to comment.