Socket
Socket
Sign inDemoInstall

node-gyp

Package Overview
Dependencies
Maintainers
5
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-gyp - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

CHANGELOG.md

2

bin/node-gyp.js

@@ -128,3 +128,3 @@ #!/usr/bin/env node

, 'Try to update node-gyp and file an Issue if it does not help:'
, ' <https://github.com/TooTallNate/node-gyp/issues>'
, ' <https://github.com/nodejs/node-gyp/issues>'
].join('\n'))

@@ -131,0 +131,0 @@ }

@@ -16,2 +16,3 @@

, exec = require('child_process').exec
, processRelease = require('./process-release')
, win = process.platform == 'win32'

@@ -22,4 +23,4 @@

function build (gyp, argv, callback) {
var makeCommand = gyp.opts.make || process.env.MAKE
var release = processRelease(argv, gyp, process.version, process.release)
, makeCommand = gyp.opts.make || process.env.MAKE
|| (process.platform.indexOf('bsd') != -1 && process.platform.indexOf('kfreebsd') == -1 ? 'gmake' : 'make')

@@ -186,4 +187,4 @@ , command = win ? 'msbuild' : makeCommand

var buildDir = path.resolve(nodeDir, buildType)
, archNodeLibPath = path.resolve(nodeDir, arch, 'node.lib')
, buildNodeLibPath = path.resolve(buildDir, 'node.lib')
, archNodeLibPath = path.resolve(nodeDir, arch, release.name + '.lib')
, buildNodeLibPath = path.resolve(buildDir, release.name + '.lib')

@@ -195,3 +196,3 @@ mkdirp(buildDir, function (err, isNew) {

, ws = fs.createWriteStream(buildNodeLibPath)
log.verbose('copying "node.lib" for ' + arch, buildNodeLibPath)
log.verbose('copying "' + release.name + '.lib" for ' + arch, buildNodeLibPath)
rs.pipe(ws)

@@ -198,0 +199,0 @@ rs.on('error', callback)

@@ -18,2 +18,3 @@ module.exports = exports = configure

, extend = require('util')._extend
, processRelease = require('./process-release')
, spawn = cp.spawn

@@ -32,2 +33,3 @@ , execFile = cp.execFile

, nodeDir
, release = processRelease(argv, gyp, process.version, process.release)

@@ -140,31 +142,21 @@ checkPython()

// if no --nodedir specified, ensure node dependencies are installed
var version
var versionStr
if (gyp.opts.target) {
if ('v' + release.version !== process.version) {
// if --target was given, then determine a target version to compile for
versionStr = gyp.opts.target
log.verbose('get node dir', 'compiling against --target node version: %s', versionStr)
log.verbose('get node dir', 'compiling against --target node version: %s', release.version)
} else {
// if no --target was specified then use the current host node version
versionStr = process.version
log.verbose('get node dir', 'no --target version specified, falling back to host node version: %s', versionStr)
log.verbose('get node dir', 'no --target version specified, falling back to host node version: %s', release.version)
}
// make sure we have a valid version
try {
version = semver.parse(versionStr)
} catch (e) {
return callback(e)
if (!release.semver) {
// could not parse the version string with semver
return callback(new Error('Invalid version number: ' + release.version))
}
if (!version) {
return callback(new Error('Invalid version number: ' + versionStr))
}
// ensure that the target node version's dev files are installed
gyp.opts.ensure = true
gyp.commands.install([ versionStr ], function (err, version) {
gyp.commands.install([ release.version ], function (err, version) {
if (err) return callback(err)
log.verbose('get node dir', 'target node version installed:', version)
nodeDir = path.resolve(gyp.devDir, version)
log.verbose('get node dir', 'target node version installed:', release.versionDir)
nodeDir = path.resolve(gyp.devDir, release.versionDir)
createBuildDir()

@@ -316,38 +308,44 @@ })

var addon_gypi = path.resolve(__dirname, '..', 'addon.gypi')
var common_gypi = path.resolve(nodeDir, 'common.gypi')
var output_dir = 'build'
if (win) {
// Windows expects an absolute path
output_dir = buildDir
}
var nodeGypDir = path.resolve(__dirname, '..')
var common_gypi = path.resolve(nodeDir, 'include/node/common.gypi')
fs.stat(common_gypi, function (err, stat) {
if (err)
common_gypi = path.resolve(nodeDir, 'common.gypi')
argv.push('-I', addon_gypi)
argv.push('-I', common_gypi)
argv.push('-Dlibrary=shared_library')
argv.push('-Dvisibility=default')
argv.push('-Dnode_root_dir=' + nodeDir)
argv.push('-Dnode_gyp_dir=' + nodeGypDir)
argv.push('-Dmodule_root_dir=' + process.cwd())
argv.push('--depth=.')
argv.push('--no-parallel')
var output_dir = 'build'
if (win) {
// Windows expects an absolute path
output_dir = buildDir
}
var nodeGypDir = path.resolve(__dirname, '..')
// tell gyp to write the Makefile/Solution files into output_dir
argv.push('--generator-output', output_dir)
argv.push('-I', addon_gypi)
argv.push('-I', common_gypi)
argv.push('-Dlibrary=shared_library')
argv.push('-Dvisibility=default')
argv.push('-Dnode_root_dir=' + nodeDir)
argv.push('-Dnode_gyp_dir=' + nodeGypDir)
argv.push('-Dnode_lib_file=' + release.name + '.lib')
argv.push('-Dmodule_root_dir=' + process.cwd())
argv.push('--depth=.')
argv.push('--no-parallel')
// tell make to write its output into the same dir
argv.push('-Goutput_dir=.')
// tell gyp to write the Makefile/Solution files into output_dir
argv.push('--generator-output', output_dir)
// enforce use of the "binding.gyp" file
argv.unshift('binding.gyp')
// tell make to write its output into the same dir
argv.push('-Goutput_dir=.')
// execute `gyp` from the current target nodedir
argv.unshift(gyp_script)
// enforce use of the "binding.gyp" file
argv.unshift('binding.gyp')
// make sure python uses files that came with this particular node package
var pypath = new PathArray(process.env, 'PYTHONPATH')
pypath.unshift(path.join(__dirname, '..', 'gyp', 'pylib'))
// execute `gyp` from the current target nodedir
argv.unshift(gyp_script)
var cp = gyp.spawn(python, argv)
cp.on('exit', onCpExit)
// make sure python uses files that came with this particular node package
var pypath = new PathArray(process.env, 'PYTHONPATH')
pypath.unshift(path.join(__dirname, '..', 'gyp', 'pylib'))
var cp = gyp.spawn(python, argv)
cp.on('exit', onCpExit)
})
}

@@ -354,0 +352,0 @@

@@ -23,2 +23,3 @@

, mkdir = require('mkdirp')
, processRelease = require('./process-release')
, win = process.platform == 'win32'

@@ -28,2 +29,4 @@

var release = processRelease(argv, gyp, process.version, process.release)
// ensure no double-callbacks happen

@@ -36,30 +39,25 @@ function cb (err) {

// roll-back the install if anything went wrong
gyp.commands.remove([ version ], function (err2) {
gyp.commands.remove([ release.versionDir ], function (err2) {
callback(err)
})
} else {
callback(null, version)
callback(null, release.version)
}
}
var distUrl = gyp.opts['dist-url'] || gyp.opts.disturl || 'https://nodejs.org/dist'
// Determine which node dev files version we are installing
var versionStr = argv[0] || gyp.opts.target || process.version
log.verbose('install', 'input version string %j', versionStr)
log.verbose('install', 'input version string %j', release.version)
// parse the version to normalize and ensure it's valid
var version = semver.parse(versionStr)
if (!version) {
return callback(new Error('Invalid version number: ' + versionStr))
if (!release.semver) {
// could not parse the version string with semver
return callback(new Error('Invalid version number: ' + release.version))
}
if (semver.lt(versionStr, '0.8.0')) {
return callback(new Error('Minimum target version is `0.8.0` or greater. Got: ' + versionStr))
if (semver.lt(release.version, '0.8.0')) {
return callback(new Error('Minimum target version is `0.8.0` or greater. Got: ' + release.version))
}
// 0.x.y-pre versions are not published yet and cannot be installed. Bail.
if (version.prerelease[0] === 'pre') {
log.verbose('detected "pre" node version', versionStr)
if (release.semver.prerelease[0] === 'pre') {
log.verbose('detected "pre" node version', release.version)
if (gyp.opts.nodedir) {

@@ -75,10 +73,6 @@ log.verbose('--nodedir flag was passed; skipping install', gyp.opts.nodedir)

// flatten version into String
version = version.version
log.verbose('install', 'installing version: %s', version)
log.verbose('install', 'installing version: %s', release.versionDir)
// distributions starting with 0.10.0 contain sha256 checksums
var checksumAlgo = semver.gte(version, '0.10.0') ? 'sha256' : 'sha1'
// the directory where the dev files will be installed
var devDir = path.resolve(gyp.devDir, version)
var devDir = path.resolve(gyp.devDir, release.versionDir)

@@ -92,3 +86,3 @@ // If '--ensure' was passed, then don't *always* install the version;

if (err.code == 'ENOENT') {
log.verbose('install', 'version not already installed, continuing with install', version)
log.verbose('install', 'version not already installed, continuing with install', release.version)
go()

@@ -150,3 +144,3 @@ } else if (err.code == 'EACCES') {

// The "request" constructor can throw sometimes apparently :(
// See: https://github.com/TooTallNate/node-gyp/issues/114
// See: https://github.com/nodejs/node-gyp/issues/114
req = request(requestOpts)

@@ -165,3 +159,3 @@ } catch (e) {

function getContentSha(res, callback) {
var shasum = crypto.createHash(checksumAlgo)
var shasum = crypto.createHash('sha256')
res.on('data', function (chunk) {

@@ -194,5 +188,4 @@ shasum.update(chunk)

// now download the node tarball
var tarPath = gyp.opts['tarball']
var tarballUrl = tarPath ? tarPath : distUrl + '/v' + version + '/node-v' + version + '.tar.gz'
, badDownload = false
var tarPath = gyp.opts.tarball
var badDownload = false
, extractCount = 0

@@ -231,3 +224,3 @@ , gunzip = zlib.createGunzip()

if (tarPath) {
var input = fs.createReadStream(tarballUrl)
var input = fs.createReadStream(tarPath)
input.pipe(gunzip).pipe(extracter)

@@ -237,3 +230,3 @@ return

var req = download(tarballUrl)
var req = download(release.tarballUrl)
if (!req) return

@@ -261,3 +254,3 @@

badDownload = true
cb(new Error(res.statusCode + ' response downloading ' + tarballUrl))
cb(new Error(res.statusCode + ' response downloading ' + release.tarballUrl))
return

@@ -267,3 +260,3 @@ }

getContentSha(res, function (_, checksum) {
var filename = path.basename(tarballUrl).trim()
var filename = path.basename(release.tarballUrl).trim()
contentShasums[filename] = checksum

@@ -329,9 +322,7 @@ log.verbose('content checksum', filename, checksum)

function downloadShasums(done) {
var shasumsFile = (checksumAlgo === 'sha256') ? 'SHASUMS256.txt' : 'SHASUMS.txt'
log.verbose('check download content checksum, need to download `' + shasumsFile + '`...')
var shasumsPath = path.resolve(devDir, shasumsFile)
, shasumsUrl = distUrl + '/v' + version + '/' + shasumsFile
log.verbose('check download content checksum, need to download `SHASUMS256.txt`...')
var shasumsPath = path.resolve(devDir, 'SHASUMS256.txt')
log.verbose('checksum url', shasumsUrl)
var req = download(shasumsUrl)
log.verbose('checksum url', release.shasumsUrl)
var req = download(release.shasumsUrl)
if (!req) return

@@ -367,14 +358,12 @@ req.on('error', done)

function downloadNodeLib (done) {
log.verbose('on Windows; need to download `node.lib`...')
log.verbose('on Windows; need to download `' + release.name + '.lib`...')
var dir32 = path.resolve(devDir, 'ia32')
, dir64 = path.resolve(devDir, 'x64')
, nodeLibPath32 = path.resolve(dir32, 'node.lib')
, nodeLibPath64 = path.resolve(dir64, 'node.lib')
, nodeLibUrl32 = distUrl + '/v' + version + '/node.lib'
, nodeLibUrl64 = distUrl + '/v' + version + '/x64/node.lib'
, libPath32 = path.resolve(dir32, release.name + '.lib')
, libPath64 = path.resolve(dir64, release.name + '.lib')
log.verbose('32-bit node.lib dir', dir32)
log.verbose('64-bit node.lib dir', dir64)
log.verbose('`node.lib` 32-bit url', nodeLibUrl32)
log.verbose('`node.lib` 64-bit url', nodeLibUrl64)
log.verbose('32-bit ' + release.name + '.lib dir', dir32)
log.verbose('64-bit ' + release.name + '.lib dir', dir64)
log.verbose('`' + release.name + '.lib` 32-bit url', release.libUrl32)
log.verbose('`' + release.name + '.lib` 64-bit url', release.libUrl64)

@@ -384,5 +373,5 @@ var async = 2

if (err) return done(err)
log.verbose('streaming 32-bit node.lib to:', nodeLibPath32)
log.verbose('streaming 32-bit ' + release.name + '.lib to:', libPath32)
var req = download(nodeLibUrl32)
var req = download(release.libUrl32)
if (!req) return

@@ -392,3 +381,3 @@ req.on('error', done)

if (res.statusCode !== 200) {
done(new Error(res.statusCode + ' status code downloading 32-bit node.lib'))
done(new Error(res.statusCode + ' status code downloading 32-bit ' + release.name + '.lib'))
return

@@ -398,7 +387,7 @@ }

getContentSha(res, function (_, checksum) {
contentShasums['node.lib'] = checksum
log.verbose('content checksum', 'node.lib', checksum)
contentShasums[release.libPath32] = checksum
log.verbose('content checksum', release.libPath32, checksum)
})
var ws = fs.createWriteStream(nodeLibPath32)
var ws = fs.createWriteStream(libPath32)
ws.on('error', cb)

@@ -413,5 +402,5 @@ req.pipe(ws)

if (err) return done(err)
log.verbose('streaming 64-bit node.lib to:', nodeLibPath64)
log.verbose('streaming 64-bit ' + release.name + '.lib to:', libPath64)
var req = download(nodeLibUrl64)
var req = download(release.libUrl64)
if (!req) return

@@ -421,3 +410,3 @@ req.on('error', done)

if (res.statusCode !== 200) {
done(new Error(res.statusCode + ' status code downloading 64-bit node.lib'))
done(new Error(res.statusCode + ' status code downloading 64-bit ' + release.name + '.lib'))
return

@@ -427,7 +416,7 @@ }

getContentSha(res, function (_, checksum) {
contentShasums['x64/node.lib'] = checksum
log.verbose('content checksum', 'x64/node.lib', checksum)
contentShasums[release.libPath64] = checksum
log.verbose('content checksum', release.libPath64, checksum)
})
var ws = fs.createWriteStream(nodeLibPath64)
var ws = fs.createWriteStream(libPath64)
ws.on('error', cb)

@@ -434,0 +423,0 @@ req.pipe(ws)

@@ -51,3 +51,3 @@

// TODO: make this *more* configurable?
// see: https://github.com/TooTallNate/node-gyp/issues/21
// see: https://github.com/nodejs/node-gyp/issues/21
var homeDir = process.env.HOME || process.env.USERPROFILE

@@ -54,0 +54,0 @@ if (!homeDir) {

@@ -22,19 +22,15 @@

// get the user-specified version to remove
var v = argv[0] || gyp.opts.target
log.verbose('remove', 'removing target version:', v)
var version = argv[0] || gyp.opts.target
log.verbose('remove', 'removing target version:', version)
if (!v) {
if (!version) {
return callback(new Error('You must specify a version number to remove. Ex: "' + process.version + '"'))
}
// parse the version to normalize and make sure it's valid
var version = semver.parse(v)
if (!version) {
return callback(new Error('Invalid version number: ' + v))
var versionSemver = semver.parse(version)
if (versionSemver) {
// flatten the version Array into a String
version = versionSemver.version
}
// flatten the version Array into a String
version = version.version
var versionPath = path.resolve(gyp.devDir, version)

@@ -41,0 +37,0 @@ log.verbose('remove', 'removing development files for version:', version)

@@ -14,3 +14,3 @@ {

],
"version": "2.0.2",
"version": "3.0.0",
"installVersion": 9,

@@ -20,3 +20,3 @@ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",

"type": "git",
"url": "git://github.com/TooTallNate/node-gyp.git"
"url": "git://github.com/nodejs/node-gyp.git"
},

@@ -29,3 +29,3 @@ "preferGlobal": true,

"glob": "3 || 4",
"graceful-fs": "3",
"graceful-fs": "^4.1.2",
"minimatch": "1",

@@ -39,3 +39,3 @@ "mkdirp": "^0.5.0",

"rimraf": "2",
"semver": "2.x || 3.x || 4",
"semver": "2.x || 3.x || 4 || 5",
"tar": "^1.0.0",

@@ -46,3 +46,9 @@ "which": "1"

"node": ">= 0.8.0"
},
"devDependencies": {
"tape": "~4.2.0"
},
"scripts": {
"test": "tape test/test-*"
}
}

@@ -142,3 +142,3 @@ node-gyp

* [gyp input format reference](https://chromium.googlesource.com/external/gyp/+/master/docs/InputFormatReference.md)
* [*"binding.gyp" files out in the wild* wiki page](https://github.com/TooTallNate/node-gyp/wiki/%22binding.gyp%22-files-out-in-the-wild)
* [*"binding.gyp" files out in the wild* wiki page](https://github.com/nodejs/node-gyp/wiki/%22binding.gyp%22-files-out-in-the-wild)

@@ -145,0 +145,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc