Socket
Socket
Sign inDemoInstall

node-gyp

Package Overview
Dependencies
Maintainers
4
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 5.0.2 to 5.0.3

lib/find-python.js

29

bin/node-gyp.js
#!/usr/bin/env node
'use strict'
process.title = 'node-gyp'
var envPaths = require('env-paths')
var gyp = require('../')
var log = require('npmlog')
var os = require('os')
const envPaths = require('env-paths')
const gyp = require('../')
const log = require('npmlog')
const os = require('os')

@@ -14,3 +16,3 @@ /**

var prog = gyp()
const prog = gyp()
var completed = false

@@ -28,4 +30,4 @@ prog.parseArgv(process.argv)

"node-gyp requires that the user's home directory is specified " +
"in either of the environmental variables HOME or USERPROFILE. " +
"Overide with: --devdir /path/to/.node-gyp")
'in either of the environmental variables HOME or USERPROFILE. ' +
'Overide with: --devdir /path/to/.node-gyp')
}

@@ -47,3 +49,2 @@

/**

@@ -90,3 +91,3 @@ * Change dir if -C/--directory was passed.

}
if (command.name == 'list') {
if (command.name === 'list') {
var versions = arguments[1]

@@ -129,3 +130,3 @@ if (versions.length > 0) {

log.error('command', process.argv
.map(JSON.stringify).join(' '))
.map(JSON.stringify).join(' '))
log.error('cwd', process.cwd())

@@ -138,6 +139,6 @@ log.error('node -v', process.version)

errorMessage()
log.error('', [ 'This is a bug in `node-gyp`.'
, 'Try to update node-gyp and file an Issue if it does not help:'
, ' <https://github.com/nodejs/node-gyp/issues>'
].join('\n'))
log.error('', [ 'This is a bug in `node-gyp`.',
'Try to update node-gyp and file an Issue if it does not help:',
' <https://github.com/nodejs/node-gyp/issues>'
].join('\n'))
}

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

@@ -0,1 +1,13 @@

v5.0.3 2019-07-17
=================
* [[`66ad305775`](https://github.com/nodejs/node-gyp/commit/66ad305775)] - **python**: accept Python 3 conditionally (João Reis) [#1815](https://github.com/nodejs/node-gyp/pull/1815)
* [[`7e7fce3fed`](https://github.com/nodejs/node-gyp/commit/7e7fce3fed)] - **python**: move Python detection to its own file (João Reis) [#1815](https://github.com/nodejs/node-gyp/pull/1815)
* [[`e40c99e283`](https://github.com/nodejs/node-gyp/commit/e40c99e283)] - **src**: implement standard.js linting (Rod Vagg) [#1794](https://github.com/nodejs/node-gyp/pull/1794)
* [[`bb92c761a9`](https://github.com/nodejs/node-gyp/commit/bb92c761a9)] - **test**: add Node.js 6 on Windows to Travis CI (João Reis) [#1812](https://github.com/nodejs/node-gyp/pull/1812)
* [[`7fd924079f`](https://github.com/nodejs/node-gyp/commit/7fd924079f)] - **test**: increase tap timeout (João Reis) [#1812](https://github.com/nodejs/node-gyp/pull/1812)
* [[`7e8127068f`](https://github.com/nodejs/node-gyp/commit/7e8127068f)] - **test**: cover supported node versions with travis (Rod Vagg) [#1809](https://github.com/nodejs/node-gyp/pull/1809)
* [[`24109148df`](https://github.com/nodejs/node-gyp/commit/24109148df)] - **test**: downgrade to tap@^12 for continued Node 6 support (Rod Vagg) [#1808](https://github.com/nodejs/node-gyp/pull/1808)
* [[`656117cc4a`](https://github.com/nodejs/node-gyp/commit/656117cc4a)] - **win**: make VS path match case-insensitive (João Reis) [#1806](https://github.com/nodejs/node-gyp/pull/1806)
v5.0.2 2019-06-27

@@ -2,0 +14,0 @@ =================

@@ -0,11 +1,10 @@

'use strict'
module.exports = exports = build
const fs = require('graceful-fs')
const path = require('path')
const glob = require('glob')
const log = require('npmlog')
const which = require('which')
const win = process.platform === 'win32'
var fs = require('graceful-fs')
, path = require('path')
, glob = require('glob')
, log = require('npmlog')
, which = require('which')
, win = process.platform === 'win32'
exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module'

@@ -20,3 +19,3 @@

} else if (win && argv.length > 0) {
argv = argv.map(function(target) {
argv = argv.map(function (target) {
return '/t:' + target

@@ -27,8 +26,9 @@ })

var makeCommand = gyp.opts.make || process.env.MAKE || platformMake
, command = win ? 'msbuild' : makeCommand
, jobs = gyp.opts.jobs || process.env.JOBS
, buildType
, config
, arch
, nodeDir
var command = win ? 'msbuild' : makeCommand
var jobs = gyp.opts.jobs || process.env.JOBS
var buildType
var config
var arch
var nodeDir
var guessedSolution

@@ -43,5 +43,6 @@ loadConfigGypi()

var configPath = path.resolve('build', 'config.gypi')
fs.readFile(configPath, 'utf8', function (err, data) {
if (err) {
if (err.code == 'ENOENT') {
if (err.code === 'ENOENT') {
callback(new Error('You must run `node-gyp configure` first!'))

@@ -53,3 +54,3 @@ } else {

}
config = JSON.parse(data.replace(/\#.+\n/, ''))
config = JSON.parse(data.replace(/#.+\n/, ''))

@@ -86,3 +87,5 @@ // get the 'arch', 'buildType', and 'nodeDir' vars from the config

glob('build/*.sln', function (err, files) {
if (err) return callback(err)
if (err) {
return callback(err)
}
if (files.length === 0) {

@@ -132,5 +135,8 @@ return callback(new Error('Could not find *.sln file. Did you run "configure"?'))

var verbose = log.levels[log.level] <= log.levels.verbose
var j
if (!win && verbose) {
argv.push('V=1')
}
if (win && !verbose) {

@@ -151,8 +157,8 @@ argv.push('/clp:Verbosity=minimal')

var archLower = arch.toLowerCase()
var p = archLower === 'x64' ? 'x64' :
(archLower === 'arm' ? 'ARM' :
(archLower === 'arm64' ? 'ARM64' : 'Win32'))
var p = archLower === 'x64' ? 'x64'
: (archLower === 'arm' ? 'ARM'
: (archLower === 'arm64' ? 'ARM64' : 'Win32'))
argv.push('/p:Configuration=' + buildType + ';Platform=' + p)
if (jobs) {
var j = parseInt(jobs, 10)
j = parseInt(jobs, 10)
if (!isNaN(j) && j > 0) {

@@ -170,3 +176,3 @@ argv.push('/m:' + j)

if (jobs) {
var j = parseInt(jobs, 10)
j = parseInt(jobs, 10)
if (!isNaN(j) && j > 0) {

@@ -185,3 +191,3 @@ argv.push('--jobs')

var hasSln = argv.some(function (arg) {
return path.extname(arg) == '.sln'
return path.extname(arg) === '.sln'
})

@@ -207,1 +213,3 @@ if (!hasSln) {

}
module.exports = build

@@ -0,9 +1,6 @@

'use strict'
module.exports = exports = clean
const rm = require('rimraf')
const log = require('npmlog')
exports.usage = 'Removes any generated build files and the "out" dir'
var rm = require('rimraf')
var log = require('npmlog')
function clean (gyp, argv, callback) {

@@ -16,1 +13,4 @@ // Remove the 'build' dir

}
module.exports = clean
module.exports.usage = 'Removes any generated build files and the "out" dir'

@@ -1,33 +0,24 @@

module.exports = exports = configure
module.exports.test = {
PythonFinder: PythonFinder,
findAccessibleSync: findAccessibleSync,
findPython: findPython,
}
'use strict'
var fs = require('graceful-fs')
, path = require('path')
, log = require('npmlog')
, os = require('os')
, semver = require('semver')
, mkdirp = require('mkdirp')
, cp = require('child_process')
, extend = require('util')._extend
, processRelease = require('./process-release')
, win = process.platform === 'win32'
, findNodeDirectory = require('./find-node-directory')
, msgFormat = require('util').format
, logWithPrefix = require('./util').logWithPrefix
if (win)
const fs = require('graceful-fs')
const path = require('path')
const log = require('npmlog')
const os = require('os')
const mkdirp = require('mkdirp')
const processRelease = require('./process-release')
const win = process.platform === 'win32'
const findNodeDirectory = require('./find-node-directory')
const msgFormat = require('util').format
var findPython = require('./find-python')
if (win) {
var findVisualStudio = require('./find-visualstudio')
}
exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module'
function configure (gyp, argv, callback) {
var python
, buildDir = path.resolve('build')
, configNames = [ 'config.gypi', 'common.gypi' ]
, configs = []
, nodeDir
, release = processRelease(argv, gyp, process.version, process.release)
var buildDir = path.resolve('build')
var configNames = [ 'config.gypi', 'common.gypi' ]
var configs = []
var nodeDir
var release = processRelease(argv, gyp, process.version, process.release)

@@ -70,6 +61,8 @@ findPython(gyp.opts.python, function (err, found) {

// into devdir. Otherwise only install if they're not already there.
gyp.opts.ensure = gyp.opts.tarball ? false : true
gyp.opts.ensure = !gyp.opts.tarball
gyp.commands.install([ release.version ], function (err) {
if (err) return callback(err)
if (err) {
return callback(err)
}
log.verbose('get node dir', 'target node version installed:', release.versionDir)

@@ -85,3 +78,5 @@ nodeDir = path.resolve(gyp.devDir, release.versionDir)

mkdirp(buildDir, function (err, isNew) {
if (err) return callback(err)
if (err) {
return callback(err)
}
log.verbose('build dir', '"build" dir needed to be created?', isNew)

@@ -98,3 +93,5 @@ if (win) {

function createConfigFile (err, vsInfo) {
if (err) return callback(err)
if (err) {
return callback(err)
}

@@ -107,10 +104,14 @@ var configFilename = 'config.gypi'

var config = process.config || {}
, defaults = config.target_defaults
, variables = config.variables
var defaults = config.target_defaults
var variables = config.variables
// default "config.variables"
if (!variables) variables = config.variables = {}
if (!variables) {
variables = config.variables = {}
}
// default "config.defaults"
if (!defaults) defaults = config.target_defaults = {}
if (!defaults) {
defaults = config.target_defaults = {}
}

@@ -130,2 +131,3 @@ // don't inherit the "defaults" from node's `process.config` object.

}
if (!defaults.default_configuration) {

@@ -137,3 +139,3 @@ defaults.default_configuration = 'Release'

variables.target_arch = gyp.opts.arch || process.arch || 'ia32'
if (variables.target_arch == 'arm64') {
if (variables.target_arch === 'arm64') {
defaults['msvs_configuration_platform'] = 'ARM64'

@@ -155,3 +157,3 @@ }

}
if (variables.target_arch == 'arm64') {
if (variables.target_arch === 'arm64') {
if (vsInfo.versionMajor > 15 ||

@@ -173,4 +175,8 @@ (vsInfo.versionMajor === 15 && vsInfo.versionMajor >= 9)) {

Object.keys(gyp.opts).forEach(function (opt) {
if (opt === 'argv') return
if (opt in gyp.configDefs) return
if (opt === 'argv') {
return
}
if (opt in gyp.configDefs) {
return
}
variables[opt.replace(/-/g, '_')] = gyp.opts[opt]

@@ -181,4 +187,5 @@ })

function boolsToString (k, v) {
if (typeof v === 'boolean')
if (typeof v === 'boolean') {
return String(v)
}
return v

@@ -191,17 +198,24 @@ }

var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step'
, json = JSON.stringify(config, boolsToString, 2)
var json = JSON.stringify(config, boolsToString, 2)
log.verbose('build/' + configFilename, 'writing out config file: %s', configPath)
configs.push(configPath)
fs.writeFile(configPath, [prefix, json, ''].join('\n'), findConfigs)
fs.writeFile(configPath, [ prefix, json, '' ].join('\n'), findConfigs)
}
function findConfigs (err) {
if (err) return callback(err)
if (err) {
return callback(err)
}
var name = configNames.shift()
if (!name) return runGyp()
if (!name) {
return runGyp()
}
var fullPath = path.resolve(name)
log.verbose(name, 'checking for gypi file: %s', fullPath)
fs.stat(fullPath, function (err) {
if (err) {
if (err.code == 'ENOENT') {
if (err.code === 'ENOENT') {
findConfigs() // check next gypi filename

@@ -220,3 +234,5 @@ } else {

function runGyp (err) {
if (err) return callback(err)
if (err) {
return callback(err)
}

@@ -242,29 +258,33 @@ if (!~argv.indexOf('-f') && !~argv.indexOf('--format')) {

// which contains the symbols needed for linking.
var node_exp_file = undefined
var nodeExpFile
if (process.platform === 'aix' || process.platform === 'os390') {
var ext = process.platform === 'aix' ? 'exp' : 'x'
var node_root_dir = findNodeDirectory()
var candidates = undefined
var nodeRootDir = findNodeDirectory()
var candidates
if (process.platform === 'aix') {
candidates = ['include/node/node',
'out/Release/node',
'out/Debug/node',
'node'
].map(function(file) {
return file + '.' + ext
})
candidates = [
'include/node/node',
'out/Release/node',
'out/Debug/node',
'node'
].map(function (file) {
return file + '.' + ext
})
} else {
candidates = ['out/Release/obj.target/libnode',
'out/Debug/obj.target/libnode',
'lib/libnode'
].map(function(file) {
return file + '.' + ext
})
candidates = [
'out/Release/obj.target/libnode',
'out/Debug/obj.target/libnode',
'lib/libnode'
].map(function (file) {
return file + '.' + ext
})
}
var logprefix = 'find exports file'
node_exp_file = findAccessibleSync(logprefix, node_root_dir, candidates)
if (node_exp_file !== undefined) {
log.verbose(logprefix, 'Found exports file: %s', node_exp_file)
nodeExpFile = findAccessibleSync(logprefix, nodeRootDir, candidates)
if (nodeExpFile !== undefined) {
log.verbose(logprefix, 'Found exports file: %s', nodeExpFile)
} else {
var msg = msgFormat('Could not find node.%s file in %s', ext, node_root_dir)
var msg = msgFormat('Could not find node.%s file in %s', ext, nodeRootDir)
log.error(logprefix, 'Could not find exports file')

@@ -276,13 +296,14 @@ return callback(new Error(msg))

// this logic ported from the old `gyp_addon` python file
var gyp_script = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
var addon_gypi = path.resolve(__dirname, '..', 'addon.gypi')
var common_gypi = path.resolve(nodeDir, 'include/node/common.gypi')
fs.stat(common_gypi, function (err) {
if (err)
common_gypi = path.resolve(nodeDir, 'common.gypi')
var gypScript = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
var addonGypi = path.resolve(__dirname, '..', 'addon.gypi')
var commonGypi = path.resolve(nodeDir, 'include/node/common.gypi')
fs.stat(commonGypi, function (err) {
if (err) {
commonGypi = path.resolve(nodeDir, 'common.gypi')
}
var output_dir = 'build'
var outputDir = 'build'
if (win) {
// Windows expects an absolute path
output_dir = buildDir
outputDir = buildDir
}

@@ -294,4 +315,4 @@ var nodeGypDir = path.resolve(__dirname, '..')

argv.push('-I', addon_gypi)
argv.push('-I', common_gypi)
argv.push('-I', addonGypi)
argv.push('-I', commonGypi)
argv.push('-Dlibrary=shared_library')

@@ -301,3 +322,3 @@ argv.push('-Dvisibility=default')

if (process.platform === 'aix' || process.platform === 'os390') {
argv.push('-Dnode_exp_file=' + node_exp_file)
argv.push('-Dnode_exp_file=' + nodeExpFile)
}

@@ -313,3 +334,3 @@ argv.push('-Dnode_gyp_dir=' + nodeGypDir)

// tell gyp to write the Makefile/Solution files into output_dir
argv.push('--generator-output', output_dir)
argv.push('--generator-output', outputDir)

@@ -323,6 +344,6 @@ // tell make to write its output into the same dir

// execute `gyp` from the current target nodedir
argv.unshift(gyp_script)
argv.unshift(gypScript)
// make sure python uses files that came with this particular node package
var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')]
var pypath = [ path.join(__dirname, '..', 'gyp', 'pylib') ]
if (process.env.PYTHONPATH) {

@@ -346,3 +367,2 @@ pypath.push(process.env.PYTHONPATH)

}
}

@@ -357,13 +377,13 @@

for (var next = 0; next < candidates.length; next++) {
var candidate = path.resolve(dir, candidates[next])
try {
var fd = fs.openSync(candidate, 'r')
} catch (e) {
// this candidate was not found or not readable, do nothing
log.silly(logprefix, 'Could not open %s: %s', candidate, e.message)
continue
}
fs.closeSync(fd)
log.silly(logprefix, 'Found readable %s', candidate)
return candidate
var candidate = path.resolve(dir, candidates[next])
try {
var fd = fs.openSync(candidate, 'r')
} catch (e) {
// this candidate was not found or not readable, do nothing
log.silly(logprefix, 'Could not open %s: %s', candidate, e.message)
continue
}
fs.closeSync(fd)
log.silly(logprefix, 'Found readable %s', candidate)
return candidate
}

@@ -374,280 +394,6 @@

function PythonFinder(configPython, callback) {
this.callback = callback
this.configPython = configPython
this.errorLog = []
module.exports = configure
module.exports.test = {
findAccessibleSync: findAccessibleSync
}
PythonFinder.prototype = {
log: logWithPrefix(log, 'find Python'),
argsExecutable: ['-c', 'import sys; print(sys.executable);'],
argsVersion: ['-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);'],
semverRange: '>=2.6.0 <3.0.0',
// These can be overridden for testing:
execFile: cp.execFile,
env: process.env,
win: win,
pyLauncher: 'py.exe',
defaultLocation: path.join(process.env.SystemDrive || 'C:', 'Python27',
'python.exe'),
// Logs a message at verbose level, but also saves it to be displayed later
// at error level if an error occurs. This should help diagnose the problem.
addLog: function addLog(message) {
this.log.verbose(message)
this.errorLog.push(message)
},
// Find Python by trying a sequence of possibilities.
// Ignore errors, keep trying until Python is found.
findPython: function findPython() {
const SKIP=0, FAIL=1
const toCheck = [
{
before: () => {
if (!this.configPython) {
this.addLog(
'Python is not set from command line or npm configuration')
return SKIP
}
this.addLog('checking Python explicitly set from command line or ' +
'npm configuration')
this.addLog('- "--python=" or "npm config get python" is ' +
`"${this.configPython}"`)
},
check: this.checkCommand,
arg: this.configPython,
},
{
before: () => {
if (!this.env.PYTHON) {
this.addLog('Python is not set from environment variable PYTHON')
return SKIP
}
this.addLog(
'checking Python explicitly set from environment variable PYTHON')
this.addLog(`- process.env.PYTHON is "${this.env.PYTHON}"`)
},
check: this.checkCommand,
arg: this.env.PYTHON,
},
{
before: () => { this.addLog('checking if "python2" can be used') },
check: this.checkCommand,
arg: 'python2',
},
{
before: () => { this.addLog('checking if "python" can be used') },
check: this.checkCommand,
arg: 'python',
},
{
before: () => {
if (!this.win) {
// Everything after this is Windows specific
return FAIL
}
this.addLog(
'checking if the py launcher can be used to find Python 2')
},
check: this.checkPyLauncher,
},
{
before: () => {
this.addLog(
'checking if Python 2 is installed in the default location')
},
check: this.checkExecPath,
arg: this.defaultLocation,
},
]
function runChecks(err) {
this.log.silly('runChecks: err = %j', err && err.stack || err)
const check = toCheck.shift()
if (!check) {
return this.fail()
}
const before = check.before.apply(this)
if (before === SKIP) {
return runChecks.apply(this)
}
if (before === FAIL) {
return this.fail()
}
const args = [ runChecks.bind(this) ]
if (check.arg) {
args.unshift(check.arg)
}
check.check.apply(this, args)
}
runChecks.apply(this)
},
// Check if command is a valid Python to use.
// Will exit the Python finder on success.
// If on Windows, run in a CMD shell to support BAT/CMD launchers.
checkCommand: function checkCommand (command, errorCallback) {
var exec = command
var args = this.argsExecutable
var shell = false
if (this.win) {
// Arguments have to be manually quoted
exec = `"${exec}"`
args = args.map(a => `"${a}"`)
shell = true
}
this.log.verbose(`- executing "${command}" to get executable path`)
this.run(exec, args, shell, function (err, execPath) {
// Possible outcomes:
// - Error: not in PATH, not executable or execution fails
// - Gibberish: the next command to check version will fail
// - Absolute path to executable
if (err) {
this.addLog(`- "${command}" is not in PATH or produced an error`)
return errorCallback(err)
}
this.addLog(`- executable path is "${execPath}"`)
this.checkExecPath(execPath, errorCallback)
}.bind(this))
},
// Check if the py launcher can find a valid Python to use.
// Will exit the Python finder on success.
// Distributions of Python on Windows by default install with the "py.exe"
// Python launcher which is more likely to exist than the Python executable
// being in the $PATH.
// Because the Python launcher supports all versions of Python, we have to
// explicitly request a Python 2 version. This is done by supplying "-2" as
// the first command line argument. Since "py.exe -2" would be an invalid
// executable for "execFile", we have to use the launcher to figure out
// where the actual "python.exe" executable is located.
checkPyLauncher: function checkPyLauncher (errorCallback) {
this.log.verbose(
`- executing "${this.pyLauncher}" to get Python 2 executable path`)
this.run(this.pyLauncher, ['-2', ...this.argsExecutable], false,
function (err, execPath) {
// Possible outcomes: same as checkCommand
if (err) {
this.addLog(
`- "${this.pyLauncher}" is not in PATH or produced an error`)
return errorCallback(err)
}
this.addLog(`- executable path is "${execPath}"`)
this.checkExecPath(execPath, errorCallback)
}.bind(this))
},
// Check if a Python executable is the correct version to use.
// Will exit the Python finder on success.
checkExecPath: function checkExecPath (execPath, errorCallback) {
this.log.verbose(`- executing "${execPath}" to get version`)
this.run(execPath, this.argsVersion, false, function (err, version) {
// Possible outcomes:
// - Error: executable can not be run (likely meaning the command wasn't
// a Python executable and the previous command produced gibberish)
// - Gibberish: somehow the last command produced an executable path,
// this will fail when verifying the version
// - Version of the Python executable
if (err) {
this.addLog(`- "${execPath}" could not be run`)
return errorCallback(err)
}
this.addLog(`- version is "${version}"`)
const range = semver.Range(this.semverRange)
var valid = false
try {
valid = range.test(version)
} catch (err) {
this.log.silly('range.test() threw:\n%s', err.stack)
this.addLog(`- "${execPath}" does not have a valid version`)
this.addLog('- is it a Python executable?')
return errorCallback(err)
}
if (!valid) {
this.addLog(`- version is ${version} - should be ${this.semverRange}`)
this.addLog('- THIS VERSION OF PYTHON IS NOT SUPPORTED')
return errorCallback(new Error(
`Found unsupported Python version ${version}`))
}
this.succeed(execPath, version)
}.bind(this))
},
// Run an executable or shell command, trimming the output.
run: function run(exec, args, shell, callback) {
var env = extend({}, this.env)
env.TERM = 'dumb'
const opts = { env: env, shell: shell }
this.log.silly('execFile: exec = %j', exec)
this.log.silly('execFile: args = %j', args)
this.log.silly('execFile: opts = %j', opts)
try {
this.execFile(exec, args, opts, execFileCallback.bind(this))
} catch (err) {
this.log.silly('execFile: threw:\n%s', err.stack)
return callback(err)
}
function execFileCallback(err, stdout, stderr) {
this.log.silly('execFile result: err = %j', err && err.stack || err)
this.log.silly('execFile result: stdout = %j', stdout)
this.log.silly('execFile result: stderr = %j', stderr)
if (err) {
return callback(err)
}
const execPath = stdout.trim()
callback(null, execPath)
}
},
succeed: function succeed(execPath, version) {
this.log.info(`using Python version ${version} found at "${execPath}"`)
process.nextTick(this.callback.bind(null, null, execPath))
},
fail: function fail() {
const errorLog = this.errorLog.join('\n')
const pathExample = this.win ? 'C:\\Path\\To\\python.exe' :
'/path/to/pythonexecutable'
// For Windows 80 col console, use up to the column before the one marked
// with X (total 79 chars including logger prefix, 58 chars usable here):
// X
const info = [
'**********************************************************',
'You need to install the latest version of Python 2.7.',
'Node-gyp should be able to find and use Python. If not,',
'you can try one of the following options:',
`- Use the switch --python="${pathExample}"`,
' (accepted by both node-gyp and npm)',
'- Set the environment variable PYTHON',
'- Set the npm configuration variable python:',
` npm config set python "${pathExample}"`,
'For more information consult the documentation at:',
'https://github.com/nodejs/node-gyp#installation',
'**********************************************************',
].join('\n')
this.log.error(`\n${errorLog}\n\n${info}\n`)
process.nextTick(this.callback.bind(null, new Error (
'Could not find any Python 2 installation to use')))
},
}
function findPython (configPython, callback) {
var finder = new PythonFinder(configPython, callback)
finder.findPython()
}
module.exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module'

@@ -1,5 +0,7 @@

var path = require('path')
, log = require('npmlog')
'use strict'
module.exports = function findNodeDirectory(scriptLocation, processObj) {
const path = require('path')
const log = require('npmlog')
function findNodeDirectory (scriptLocation, processObj) {
// set dirname and process if not passed in

@@ -15,15 +17,15 @@ // this facilitates regression tests

// Have a look to see what is above us, to try and work out where we are
npm_parent_directory = path.join(scriptLocation, '../../../..')
log.verbose('node-gyp root', 'npm_parent_directory is '
+ path.basename(npm_parent_directory))
node_root_dir = ""
var npmParentDirectory = path.join(scriptLocation, '../../../..')
log.verbose('node-gyp root', 'npm_parent_directory is ' +
path.basename(npmParentDirectory))
var nodeRootDir = ''
log.verbose('node-gyp root', 'Finding node root directory')
if (path.basename(npm_parent_directory) === 'deps') {
if (path.basename(npmParentDirectory) === 'deps') {
// We are in a build directory where this script lives in
// deps/npm/node_modules/node-gyp/lib
node_root_dir = path.join(npm_parent_directory, '..')
log.verbose('node-gyp root', 'in build directory, root = '
+ node_root_dir)
} else if (path.basename(npm_parent_directory) === 'node_modules') {
nodeRootDir = path.join(npmParentDirectory, '..')
log.verbose('node-gyp root', 'in build directory, root = ' +
nodeRootDir)
} else if (path.basename(npmParentDirectory) === 'node_modules') {
// We are in a node install directory where this script lives in

@@ -34,16 +36,16 @@ // lib/node_modules/npm/node_modules/node-gyp/lib or

if (processObj.platform === 'win32') {
node_root_dir = path.join(npm_parent_directory, '..')
nodeRootDir = path.join(npmParentDirectory, '..')
} else {
node_root_dir = path.join(npm_parent_directory, '../..')
nodeRootDir = path.join(npmParentDirectory, '../..')
}
log.verbose('node-gyp root', 'in install directory, root = '
+ node_root_dir)
log.verbose('node-gyp root', 'in install directory, root = ' +
nodeRootDir)
} else {
// We don't know where we are, try working it out from the location
// of the node binary
var node_dir = path.dirname(processObj.execPath)
var directory_up = path.basename(node_dir)
if (directory_up === 'bin') {
node_root_dir = path.join(node_dir, '..')
} else if (directory_up === 'Release' || directory_up === 'Debug') {
var nodeDir = path.dirname(processObj.execPath)
var directoryUp = path.basename(nodeDir)
if (directoryUp === 'bin') {
nodeRootDir = path.join(nodeDir, '..')
} else if (directoryUp === 'Release' || directoryUp === 'Debug') {
// If we are a recently built node, and the directory structure

@@ -53,5 +55,5 @@ // is that of a repository. If we are on Windows then we only need

if (processObj.platform === 'win32') {
node_root_dir = path.join(node_dir, '..')
nodeRootDir = path.join(nodeDir, '..')
} else {
node_root_dir = path.join(node_dir, '../..')
nodeRootDir = path.join(nodeDir, '../..')
}

@@ -61,3 +63,5 @@ }

}
return node_root_dir
return nodeRootDir
}
module.exports = findNodeDirectory

@@ -1,6 +0,2 @@

module.exports = exports = findVisualStudio
module.exports.test = {
VisualStudioFinder: VisualStudioFinder,
findVisualStudio: findVisualStudio
}
'use strict'

@@ -135,5 +131,9 @@ const log = require('npmlog')

var csFile = path.join(__dirname, 'Find-VisualStudio.cs')
var psArgs = ['-ExecutionPolicy', 'Unrestricted', '-NoProfile',
'-Command', '&{Add-Type -Path \'' + csFile + '\';' +
'[VisualStudioConfiguration.Main]::PrintJson()}']
var psArgs = [
'-ExecutionPolicy',
'Unrestricted',
'-NoProfile',
'-Command',
'&{Add-Type -Path \'' + csFile + '\';' + '[VisualStudioConfiguration.Main]::PrintJson()}'
]

@@ -192,3 +192,5 @@ this.log.silly('Running', ps, psArgs)

vsInfo = vsInfo.filter((info) => {
if (info.versionYear) { return true }
if (info.versionYear) {
return true
}
this.addLog(`unknown version "${info.version}" found at "${info.path}"`)

@@ -408,7 +410,9 @@ return false

}
if (this.configPath && this.configPath !== vsPath) {
if (this.configPath &&
path.relative(this.configPath, vsPath) !== '') {
this.addLog('- msvs_version does not point to this installation')
return false
}
if (this.envVcInstallDir && this.envVcInstallDir !== vsPath) {
if (this.envVcInstallDir &&
path.relative(this.envVcInstallDir, vsPath) !== '') {
this.addLog('- does not match this Visual Studio Command Prompt')

@@ -421,1 +425,7 @@ return false

}
module.exports = findVisualStudio
module.exports.test = {
VisualStudioFinder: VisualStudioFinder,
findVisualStudio: findVisualStudio
}

@@ -1,25 +0,15 @@

module.exports = exports = function (gyp, argv, callback) {
return install(fs, gyp, argv, callback)
}
'use strict'
module.exports.test = {
download: download,
install: install,
readCAFile: readCAFile,
}
const fs = require('graceful-fs')
const os = require('os')
const tar = require('tar')
const path = require('path')
const crypto = require('crypto')
const log = require('npmlog')
const semver = require('semver')
const request = require('request')
const mkdir = require('mkdirp')
const processRelease = require('./process-release')
const win = process.platform === 'win32'
exports.usage = 'Install node development files for the specified node version.'
var fs = require('graceful-fs')
, os = require('os')
, tar = require('tar')
, path = require('path')
, crypto = require('crypto')
, log = require('npmlog')
, semver = require('semver')
, request = require('request')
, mkdir = require('mkdirp')
, processRelease = require('./process-release')
, win = process.platform == 'win32'
function install (fs, gyp, argv, callback) {

@@ -30,3 +20,5 @@ var release = processRelease(argv, gyp, process.version, process.release)

function cb (err) {
if (cb.done) return
if (cb.done) {
return
}
cb.done = true

@@ -80,6 +72,6 @@ if (err) {

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

@@ -94,3 +86,3 @@ } else {

fs.readFile(installVersionFile, 'ascii', function (err, ver) {
if (err && err.code != 'ENOENT') {
if (err && err.code !== 'ENOENT') {
return cb(err)

@@ -114,3 +106,3 @@ }

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

@@ -130,3 +122,3 @@ res.on('data', function (chunk) {

if (err) {
if (err.code == 'EACCES') {
if (err.code === 'EACCES') {
eaccesFallback(err)

@@ -146,4 +138,3 @@ } else {

var badDownload = false
, extractCount = 0
var extractCount = 0
var contentShasums = {}

@@ -222,3 +213,5 @@ var expectShasums = {}

function afterTarball () {
if (badDownload) return
if (badDownload) {
return
}
if (extractCount === 0) {

@@ -254,3 +247,5 @@ return cb(new Error('There was a fatal problem while downloading/extracting the tarball'))

function deref (err) {
if (err) return cb(err)
if (err) {
return cb(err)
}

@@ -273,3 +268,3 @@ async--

function downloadShasums(done) {
function downloadShasums (done) {
log.verbose('check download content checksum, need to download `SHASUMS256.txt`...')

@@ -298,3 +293,5 @@ log.verbose('checksum url', release.shasumsUrl)

var items = line.trim().split(/\s+/)
if (items.length !== 2) return
if (items.length !== 2) {
return
}

@@ -326,3 +323,5 @@ // 0035d18e2dcf9aad669b1c7c07319e17abfe3762 ./node-v0.11.4.tar.gz

mkdir(dir, function (err) {
if (err) return done(err)
if (err) {
return done(err)
}
log.verbose('streaming', name, 'to:', targetLibPath)

@@ -356,5 +355,3 @@

} // downloadNodeLib()
}) // mkdir()
} // go()

@@ -368,4 +365,4 @@

// header files
var extname = path.extname(file);
return extname === '.h' || extname === '.gypi';
var extname = path.extname(file)
return extname === '.h' || extname === '.gypi'
}

@@ -384,3 +381,5 @@

var noretry = '--node_gyp_internal_noretry'
if (-1 !== argv.indexOf(noretry)) return cb(err)
if (argv.indexOf(noretry) !== -1) {
return cb(err)
}
var tmpdir = os.tmpdir()

@@ -390,3 +389,3 @@ gyp.devDir = path.resolve(tmpdir, '.node-gyp')

log.warn('EACCES', 'attempting to reinstall using temporary dev dir "%s"', gyp.devDir)
if (process.cwd() == tmpdir) {
if (process.cwd() === tmpdir) {
log.verbose('tmpdir == cwd', 'automatically will remove dev files after to save disk space')

@@ -397,3 +396,2 @@ gyp.todo.push({ name: 'remove', args: argv })

}
}

@@ -405,6 +403,6 @@

var requestOpts = {
uri: url
, headers: {
'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')'
}
uri: url,
headers: {
'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')'
}
}

@@ -418,6 +416,6 @@

// basic support for a proxy server
var proxyUrl = gyp.opts.proxy
|| env.http_proxy
|| env.HTTP_PROXY
|| env.npm_config_proxy
var proxyUrl = gyp.opts.proxy ||
env.http_proxy ||
env.HTTP_PROXY ||
env.npm_config_proxy
if (proxyUrl) {

@@ -447,1 +445,11 @@ if (/^https?:\/\//i.test(proxyUrl)) {

}
module.exports = function (gyp, argv, callback) {
return install(fs, gyp, argv, callback)
}
module.exports.test = {
download: download,
install: install,
readCAFile: readCAFile
}
module.exports.usage = 'Install node development files for the specified node version.'

@@ -0,9 +1,6 @@

'use strict'
module.exports = exports = list
const fs = require('graceful-fs')
const log = require('npmlog')
exports.usage = 'Prints a listing of the currently installed node development files'
var fs = require('graceful-fs')
, log = require('npmlog')
function list (gyp, args, callback) {

@@ -16,7 +13,8 @@ var devDir = gyp.devDir

function onreaddir (err, versions) {
if (err && err.code != 'ENOENT') {
if (err && err.code !== 'ENOENT') {
return callback(err)
}
if (Array.isArray(versions)) {
versions = versions.filter(function (v) { return v != 'current' })
versions = versions.filter(function (v) { return v !== 'current' })
} else {

@@ -28,1 +26,4 @@ versions = []

}
module.exports = list
exports.usage = 'Prints a listing of the currently installed node development files'

@@ -0,26 +1,25 @@

'use strict'
module.exports = exports = gyp
const path = require('path')
const nopt = require('nopt')
const log = require('npmlog')
const childProcess = require('child_process')
const EE = require('events').EventEmitter
const inherits = require('util').inherits
const commands = [
// Module build commands
'build',
'clean',
'configure',
'rebuild',
// Development Header File management commands
'install',
'list',
'remove'
]
const aliases = {
'ls': 'list',
'rm': 'remove'
}
var path = require('path')
, nopt = require('nopt')
, log = require('npmlog')
, child_process = require('child_process')
, EE = require('events').EventEmitter
, inherits = require('util').inherits
, commands = [
// Module build commands
'build'
, 'clean'
, 'configure'
, 'rebuild'
// Development Header File management commands
, 'install'
, 'list'
, 'remove'
]
, aliases = {
'ls': 'list'
, 'rm': 'remove'
}
// differentiate node-gyp's logs from npm's

@@ -61,20 +60,20 @@ log.heading = 'gyp'

proto.configDefs = {
help: Boolean // everywhere
, arch: String // 'configure'
, cafile: String // 'install'
, debug: Boolean // 'build'
, directory: String // bin
, make: String // 'build'
, msvs_version: String // 'configure'
, ensure: Boolean // 'install'
, solution: String // 'build' (windows only)
, proxy: String // 'install'
, devdir: String // everywhere
, nodedir: String // 'configure'
, loglevel: String // everywhere
, python: String // 'configure'
, 'dist-url': String // 'install'
, 'tarball': String // 'install'
, jobs: String // 'build'
, thin: String // 'configure'
help: Boolean, // everywhere
arch: String, // 'configure'
cafile: String, // 'install'
debug: Boolean, // 'build'
directory: String, // bin
make: String, // 'build'
msvs_version: String, // 'configure'
ensure: Boolean, // 'install'
solution: String, // 'build' (windows only)
proxy: String, // 'install'
devdir: String, // everywhere
nodedir: String, // 'configure'
loglevel: String, // everywhere
python: String, // 'configure'
'dist-url': String, // 'install'
'tarball': String, // 'install'
jobs: String, // 'build'
thin: String // 'configure'
}

@@ -87,9 +86,9 @@

proto.shorthands = {
release: '--no-debug'
, C: '--directory'
, debug: '--debug'
, j: '--jobs'
, silly: '--loglevel=silly'
, verbose: '--loglevel=verbose'
, silent: '--loglevel=silent'
release: '--no-debug',
C: '--directory',
debug: '--debug',
j: '--jobs',
silly: '--loglevel=silly',
verbose: '--loglevel=verbose',
silent: '--loglevel=silent'
}

@@ -139,14 +138,18 @@

// support for inheriting config env variables from npm
var npm_config_prefix = 'npm_config_'
var npmConfigPrefix = 'npm_config_'
Object.keys(process.env).forEach(function (name) {
if (name.indexOf(npm_config_prefix) !== 0) return
if (name.indexOf(npmConfigPrefix) !== 0) {
return
}
var val = process.env[name]
if (name === npm_config_prefix + 'loglevel') {
if (name === npmConfigPrefix + 'loglevel') {
log.level = val
} else {
// add the user-defined options to the config
name = name.substring(npm_config_prefix.length)
name = name.substring(npmConfigPrefix.length)
// gyp@741b7f1 enters an infinite loop when it encounters
// zero-length options so ensure those don't get through.
if (name) this.opts[name] = val
if (name) {
this.opts[name] = val
}
}

@@ -166,7 +169,9 @@ }, this)

proto.spawn = function spawn (command, args, opts) {
if (!opts) opts = {}
if (!opts) {
opts = {}
}
if (!opts.silent && !opts.stdio) {
opts.stdio = [ 0, 1, 2 ]
}
var cp = child_process.spawn(command, args, opts)
var cp = childProcess.spawn(command, args, opts)
log.info('spawn', command)

@@ -183,12 +188,12 @@ log.info('spawn args', args)

var str = [
''
, ' Usage: node-gyp <command> [options]'
, ''
, ' where <command> is one of:'
, commands.map(function (c) {
return ' - ' + c + ' - ' + require('./' + c).usage
}).join('\n')
, ''
, 'node-gyp@' + this.version + ' ' + path.resolve(__dirname, '..')
, 'node@' + process.versions.node
'',
' Usage: node-gyp <command> [options]',
'',
' where <command> is one of:',
commands.map(function (c) {
return ' - ' + c + ' - ' + require('./' + c).usage
}).join('\n'),
'',
'node-gyp@' + this.version + ' ' + path.resolve(__dirname, '..'),
'node@' + process.versions.node
].join('\n')

@@ -203,6 +208,8 @@ return str

Object.defineProperty(proto, 'version', {
get: function () {
return this.package.version
}
, enumerable: true
get: function () {
return this.package.version
},
enumerable: true
})
module.exports = exports = gyp

@@ -1,12 +0,14 @@

var semver = require('semver')
, url = require('url')
, path = require('path')
, log = require('npmlog')
'use strict'
// 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"
const semver = require('semver')
const url = require('url')
const path = require('path')
const log = require('npmlog')
// versions where -headers.tar.gz started shipping
const headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42'
const bitsre = /\/win-(x86|x64)\//
const bitsreV3 = /\/win-(x86|ia32|x64)\// // io.js v3.x.x shipped with "ia32" but should
// have been "x86"
// Captures all the logic required to determine download URLs, local directory and

@@ -17,13 +19,13 @@ // file names. Inputs come from command-line switches (--target, --dist-url),

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
, isNamedForLegacyIojs
, name
, distBaseUrl
, baseUrl
, libUrl32
, libUrl64
, tarballUrl
, canGetHeaders
var versionSemver = semver.parse(version)
var overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl
var isDefaultVersion
var isNamedForLegacyIojs
var name
var distBaseUrl
var baseUrl
var libUrl32
var libUrl64
var tarballUrl
var canGetHeaders

@@ -41,4 +43,5 @@ if (!versionSemver) {

// can't use process.release if we're using --target=x.y.z
if (!isDefaultVersion)
if (!isDefaultVersion) {
defaultRelease = null
}

@@ -61,12 +64,15 @@ if (defaultRelease) {

// check for the nvm.sh standard mirror env variables
if (!overrideDistUrl && process.env.NODEJS_ORG_MIRROR)
if (!overrideDistUrl && process.env.NODEJS_ORG_MIRROR) {
overrideDistUrl = process.env.NODEJS_ORG_MIRROR
}
if (overrideDistUrl)
if (overrideDistUrl) {
log.verbose('download', 'using dist-url', overrideDistUrl)
}
if (overrideDistUrl)
if (overrideDistUrl) {
distBaseUrl = overrideDistUrl.replace(/\/+$/, '')
else
} else {
distBaseUrl = 'https://nodejs.org/dist'
}
distBaseUrl += '/v' + version + '/'

@@ -103,4 +109,10 @@

versionDir: (name !== 'node' ? name + '-' : '') + version,
ia32: { libUrl: libUrl32, libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)) },
x64: { libUrl: libUrl64, libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path)) },
ia32: {
libUrl: libUrl32,
libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path))
},
x64: {
libUrl: libUrl64,
libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path))
}
}

@@ -115,8 +127,9 @@ }

var base = url.resolve(defaultUrl, './')
, hasLibUrl = bitsre.test(defaultUrl) || (versionMajor === 3 && bitsreV3.test(defaultUrl))
var hasLibUrl = bitsre.test(defaultUrl) || (versionMajor === 3 && bitsreV3.test(defaultUrl))
if (!hasLibUrl) {
// let's assume it's a baseUrl then
if (versionMajor >= 1)
return url.resolve(base, 'win-' + arch +'/' + name + '.lib')
if (versionMajor >= 1) {
return url.resolve(base, 'win-' + arch + '/' + name + '.lib')
}
// prior to io.js@1.0.0 32-bit node.lib lives in /, 64-bit lives in /x64/

@@ -123,0 +136,0 @@ return url.resolve(base, (arch === 'x64' ? 'x64/' : '') + name + '.lib')

@@ -0,9 +1,6 @@

'use strict'
module.exports = exports = rebuild
exports.usage = 'Runs "clean", "configure" and "build" all at once'
function rebuild (gyp, argv, callback) {
gyp.todo.push(
{ name: 'clean', args: [] }
{ name: 'clean', args: [] }
, { name: 'configure', args: argv }

@@ -14,1 +11,4 @@ , { name: 'build', args: [] }

}
module.exports = rebuild
module.exports.usage = 'Runs "clean", "configure" and "build" all at once'

@@ -0,12 +1,9 @@

'use strict'
module.exports = exports = remove
const fs = require('fs')
const rm = require('rimraf')
const path = require('path')
const log = require('npmlog')
const semver = require('semver')
exports.usage = 'Removes the node development files for the specified version'
var fs = require('fs')
, rm = require('rimraf')
, path = require('path')
, log = require('npmlog')
, semver = require('semver')
function remove (gyp, argv, callback) {

@@ -36,3 +33,3 @@ var devDir = gyp.devDir

if (err) {
if (err.code == 'ENOENT') {
if (err.code === 'ENOENT') {
callback(null, 'version was already uninstalled: ' + version)

@@ -48,1 +45,4 @@ } else {

}
module.exports = exports = remove
module.exports.usage = 'Removes the node development files for the specified version'

@@ -1,6 +0,2 @@

module.exports = {
logWithPrefix: logWithPrefix,
regGetValue: regGetValue,
regSearchKeys: regSearchKeys
}
'use strict'

@@ -12,4 +8,4 @@ const log = require('npmlog')

function logWithPrefix (log, prefix) {
function setPrefix(logFunction) {
return (...args) => logFunction.apply(null, [prefix, ...args])
function setPrefix (logFunction) {
return (...args) => logFunction.apply(null, [ prefix, ...args ]) // eslint-disable-line
}

@@ -21,3 +17,3 @@ return {

warn: setPrefix(log.warn),
error: setPrefix(log.error),
error: setPrefix(log.error)
}

@@ -65,1 +61,7 @@ }

}
module.exports = {
logWithPrefix: logWithPrefix,
regGetValue: regGetValue,
regSearchKeys: regSearchKeys
}

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

],
"version": "5.0.2",
"version": "5.0.3",
"installVersion": 9,

@@ -42,14 +42,12 @@ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",

"devDependencies": {
"babel-eslint": "^8.2.5",
"bindings": "~1.2.1",
"eslint": "^5.0.1",
"nan": "^2.0.0",
"require-inject": "~1.3.0",
"tap": "~14.2.4"
"standard": "~12.0.1",
"tap": "~12.7.0"
},
"scripts": {
"lint": "eslint bin lib test",
"test": "npm run lint && tap test/test-*",
"test-ci": "npm run lint && tap -Rtap test/test-*"
"lint": "standard */*.js test/**/*.js",
"test": "npm run lint && tap --timeout=120 test/test-*"
}
}
'use strict'
var fs = require('graceful-fs')
var child_process = require('child_process')
const fs = require('graceful-fs')
const childProcess = require('child_process')
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(search, pos) {
return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search
function startsWith (str, search, pos) {
if (String.prototype.startsWith) {
return str.startsWith(search, pos)
}
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search
}
function processExecSync(file, args, options) {
function processExecSync (file, args, options) {
var child, error, timeout, tmpdir, command

@@ -25,15 +27,15 @@ command = makeCommand(file, args)

// init tmpdir
var os_temp_base = '/tmp'
var os = determine_os()
os_temp_base = '/tmp'
var osTempBase = '/tmp'
var os = determineOS()
osTempBase = '/tmp'
if (process.env.TMP) {
os_temp_base = process.env.TMP
osTempBase = process.env.TMP
}
if (os_temp_base[os_temp_base.length - 1] !== '/') {
os_temp_base += '/'
if (osTempBase[osTempBase.length - 1] !== '/') {
osTempBase += '/'
}
tmpdir = os_temp_base + 'processExecSync.' + Date.now() + Math.random()
tmpdir = osTempBase + 'processExecSync.' + Date.now() + Math.random()
fs.mkdirSync(tmpdir)

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

// init child
child = child_process.exec(command, options)
child = childProcess.exec(command, options)

@@ -70,3 +72,3 @@ var maxTry = 100000 // increases the test time by 6 seconds on win-2016-node-0.10

['stdout', 'stderr', 'status'].forEach(function (file) {
[ 'stdout', 'stderr', 'status' ].forEach(function (file) {
child[file] = fs.readFileSync(tmpdir + '/' + file, options.encoding)

@@ -90,7 +92,7 @@ setTimeout(unlinkFile, 500, tmpdir + '/' + file)

function makeCommand(file, args) {
function makeCommand (file, args) {
var command, quote
command = file
if (args.length > 0) {
for(var i in args) {
for (var i in args) {
command = command + ' '

@@ -101,3 +103,3 @@ if (args[i][0] === '-') {

if (!quote) {
command = command + '\"'
command = command + '"'
quote = true

@@ -108,3 +110,3 @@ }

if (args.length === (parseInt(i) + 1)) {
command = command + '\"'
command = command + '"'
}

@@ -118,3 +120,3 @@ }

function determine_os() {
function determineOS () {
var os = ''

@@ -124,13 +126,13 @@ var tmpVar = ''

tmpVar = process.env.OSTYPE
} else if (process.env.OS) {
} else if (process.env.OS) {
tmpVar = process.env.OS
} else {
//default is linux
// default is linux
tmpVar = 'linux'
}
if (tmpVar.startsWith('linux')) {
if (startsWith(tmpVar, 'linux')) {
os = 'linux'
}
if (tmpVar.startsWith('win')) {
if (startsWith(tmpVar, 'win')) {
os = 'win'

@@ -142,3 +144,3 @@ }

function unlinkFile(file) {
function unlinkFile (file) {
fs.unlinkSync(file)

@@ -145,0 +147,0 @@ }

@@ -1,14 +0,17 @@

var http = require('http')
, https = require('https')
, server = http.createServer(handler)
, port = +process.argv[2]
, prefix = process.argv[3]
, upstream = process.argv[4]
, calls = 0
'use strict'
const http = require('http')
const https = require('https')
const server = http.createServer(handler)
const port = +process.argv[2]
const prefix = process.argv[3]
const upstream = process.argv[4]
var calls = 0
server.listen(port)
function handler (req, res) {
if (req.url.indexOf(prefix) != 0)
if (req.url.indexOf(prefix) !== 0) {
throw new Error('request url [' + req.url + '] does not start with [' + prefix + ']')
}

@@ -18,4 +21,5 @@ var upstreamUrl = upstream + req.url.substring(prefix.length)

ures.on('end', function () {
if (++calls == 2)
if (++calls === 2) {
server.close()
}
})

@@ -22,0 +26,0 @@ ures.pipe(res)

'use strict'
var test = require('tap').test
var path = require('path')
var fs = require('graceful-fs')
var child_process = require('child_process')
var os = require('os')
var addonPath = path.resolve(__dirname, 'node_modules', 'hello_world')
var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')
var execFileSync = child_process.execFileSync || require('./process-exec-sync')
var execFile = child_process.execFile
const test = require('tap').test
const path = require('path')
const fs = require('graceful-fs')
const childProcess = require('child_process')
const os = require('os')
const addonPath = path.resolve(__dirname, 'node_modules', 'hello_world')
const nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')
const execFileSync = childProcess.execFileSync || require('./process-exec-sync')
const execFile = childProcess.execFile
function runHello(hostProcess) {
function runHello (hostProcess) {
if (!hostProcess) {

@@ -18,24 +18,15 @@ hostProcess = process.execPath

var testCode = "console.log(require('hello_world').hello())"
return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString()
return execFileSync(hostProcess, [ '-e', testCode ], { cwd: __dirname }).toString()
}
function runDuplicateBindings() {
const hostProcess = process.execPath;
var testCode =
"console.log((function(bindings) {" +
"return bindings.pointerCheck1(bindings.pointerCheck2());" +
"})(require('duplicate_symbols')))"
return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString()
}
function getEncoding() {
function getEncoding () {
var code = 'import locale;print(locale.getdefaultlocale()[1])'
return execFileSync('python', ['-c', code]).toString().trim()
return execFileSync('python', [ '-c', code ]).toString().trim()
}
function checkCharmapValid() {
function checkCharmapValid () {
var data
try {
data = execFileSync('python', ['fixtures/test-charmap.py'],
{ cwd: __dirname })
data = execFileSync('python', [ 'fixtures/test-charmap.py' ],
{ cwd: __dirname })
} catch (err) {

@@ -52,6 +43,6 @@ return false

// Set the loglevel otherwise the output disappears when run via 'npm test'
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
var cmd = [ nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose' ]
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length-1]
var lastLine = logLines[logLines.length - 1]
t.strictEqual(err, null)

@@ -65,17 +56,2 @@ t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')

test('make sure addon symbols do not overlap', function (t) {
t.plan(3)
var addonPath = path.resolve(__dirname, 'node_modules', 'duplicate_symbols')
// Set the loglevel otherwise the output disappears when run via 'npm test'
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.trim().split(/\r?\n/)
var lastLine = logLines[logLines.length-1]
t.strictEqual(err, null)
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
t.strictEqual(runDuplicateBindings().trim(), 'not equal')
})
})
test('build simple addon in path with non-ascii characters', function (t) {

@@ -102,3 +78,4 @@ t.plan(1)

var data, configPath = path.join(addonPath, 'build', 'config.gypi')
var data
var configPath = path.join(addonPath, 'build', 'config.gypi')
try {

@@ -110,3 +87,3 @@ data = fs.readFileSync(configPath, 'utf8')

}
var config = JSON.parse(data.replace(/\#.+\n/, ''))
var config = JSON.parse(data.replace(/#.+\n/, ''))
var nodeDir = config.variables.nodedir

@@ -129,4 +106,10 @@ var testNodeDir = path.join(addonPath, testDirName)

var cmd = [nodeGyp, 'rebuild', '-C', addonPath,
'--loglevel=verbose', '-nodedir=' + testNodeDir]
var cmd = [
nodeGyp,
'rebuild',
'-C',
addonPath,
'--loglevel=verbose',
'-nodedir=' + testNodeDir
]
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {

@@ -140,3 +123,3 @@ try {

var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length-1]
var lastLine = logLines[logLines.length - 1]
t.strictEqual(err, null)

@@ -153,5 +136,5 @@ t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')

if (process.version.substr(1).split('.')[0] < 8) {
t.skip("skipping test for old node version");
t.end();
return;
t.skip('skipping test for old node version')
t.end()
return
}

@@ -164,6 +147,6 @@

var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
var cmd = [ nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose' ]
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length-1]
var lastLine = logLines[logLines.length - 1]
t.strictEqual(err, null)

@@ -170,0 +153,0 @@ t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')

'use strict'
var test = require('tap').test
var path = require('path')
var gyp = require('../lib/node-gyp')
var requireInject = require('require-inject')
var configure = requireInject('../lib/configure', {
const test = require('tap').test
const path = require('path')
const gyp = require('../lib/node-gyp')
const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', {
'graceful-fs': {
'openSync': function () { return 0; },
'openSync': function () { return 0 },
'closeSync': function () { },

@@ -16,5 +16,5 @@ 'writeFile': function (file, data, cb) { cb() },

var EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
var SEPARATOR = process.platform == 'win32' ? ';' : ':'
var SPAWN_RESULT = { on: function () { } }
const EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
const SEPARATOR = process.platform === 'win32' ? ';' : ':'
const SPAWN_RESULT = { on: function () { } }

@@ -46,7 +46,6 @@ require('npmlog').level = 'warn'

prog.spawn = function () {
t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR))
t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])
t.deepEqual(dirs, [ EXPECTED_PYPATH, existingPath ])

@@ -63,3 +62,3 @@ return SPAWN_RESULT

var pythonDir2 = path.join('b', 'c')
var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
var existingPath = [ pythonDir1, pythonDir2 ].join(SEPARATOR)
process.env.PYTHONPATH = existingPath

@@ -70,7 +69,6 @@

prog.spawn = function () {
t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR))
t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
t.deepEqual(dirs, [ EXPECTED_PYPATH, pythonDir1, pythonDir2 ])

@@ -77,0 +75,0 @@ return SPAWN_RESULT

'use strict'
var test = require('tap').test
var fs = require('fs')
var http = require('http')
var https = require('https')
var install = require('../lib/install')
const test = require('tap').test
const fs = require('fs')
const path = require('path')
const http = require('http')
const https = require('https')
const install = require('../lib/install')

@@ -16,3 +17,3 @@ require('npmlog').level = 'warn'

t.strictEqual(req.headers['user-agent'],
'node-gyp v42 (node ' + process.version + ')')
'node-gyp v42 (node ' + process.version + ')')
res.end('ok')

@@ -27,3 +28,3 @@ server.close()

opts: {},
version: '42',
version: '42'
}

@@ -35,6 +36,6 @@ var url = 'http://' + host + ':' + port

res.setEncoding('utf8')
res.on('data', function(data) {
res.on('data', function (data) {
body += data
})
res.on('end', function() {
res.on('end', function () {
t.strictEqual(body, 'ok')

@@ -49,6 +50,6 @@ })

var cert = fs.readFileSync(__dirname + '/fixtures/server.crt', 'utf8')
var key = fs.readFileSync(__dirname + '/fixtures/server.key', 'utf8')
var cert = fs.readFileSync(path.join(__dirname, 'fixtures/server.crt'), 'utf8')
var key = fs.readFileSync(path.join(__dirname, 'fixtures/server.key'), 'utf8')
var cafile = __dirname + '/fixtures/ca.crt'
var cafile = path.join(__dirname, '/fixtures/ca.crt')
var ca = install.test.readCAFile(cafile)

@@ -60,3 +61,3 @@ t.strictEqual(ca.length, 1)

t.strictEqual(req.headers['user-agent'],
'node-gyp v42 (node ' + process.version + ')')
'node-gyp v42 (node ' + process.version + ')')
res.end('ok')

@@ -75,3 +76,3 @@ server.close()

opts: { cafile: cafile },
version: '42',
version: '42'
}

@@ -83,6 +84,6 @@ var url = 'https://' + host + ':' + port

res.setEncoding('utf8')
res.on('data', function(data) {
res.on('data', function (data) {
body += data
})
res.on('end', function() {
res.on('end', function () {
t.strictEqual(body, 'ok')

@@ -97,3 +98,3 @@ })

var gyp = {
opts: { cafile: 'no.such.file' },
opts: { cafile: 'no.such.file' }
}

@@ -108,3 +109,3 @@ try {

test('check certificate splitting', function (t) {
var cas = install.test.readCAFile(__dirname + '/fixtures/ca-bundle.crt')
var cas = install.test.readCAFile(path.join(__dirname, 'fixtures/ca-bundle.crt'))
t.plan(2)

@@ -111,0 +112,0 @@ t.strictEqual(cas.length, 2)

'use strict'
var test = require('tap').test
var path = require('path')
var requireInject = require('require-inject')
var configure = requireInject('../lib/configure', {
const test = require('tap').test
const path = require('path')
const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', {
'graceful-fs': {
'closeSync': function () { return undefined },
'openSync': function (path) {
if (readableFiles.some(function (f) { return f === path} )) {
if (readableFiles.some(function (f) { return f === path })) {
return 0

@@ -20,7 +20,7 @@ } else {

var dir = path.sep + 'testdir'
var readableFile = 'readable_file'
var anotherReadableFile = 'another_readable_file'
var readableFileInDir = 'somedir' + path.sep + readableFile
var readableFiles = [
const dir = path.sep + 'testdir'
const readableFile = 'readable_file'
const anotherReadableFile = 'another_readable_file'
const readableFileInDir = 'somedir' + path.sep + readableFile
const readableFiles = [
path.resolve(dir, readableFile),

@@ -63,3 +63,2 @@ path.resolve(dir, anotherReadableFile),

test('find accessible - multi item array, no matches', function (t) {

@@ -73,3 +72,2 @@ t.plan(1)

test('find accessible - multi item array, single match', function (t) {

@@ -76,0 +74,0 @@ t.plan(1)

@@ -1,7 +0,9 @@

var test = require('tap').test
var path = require('path')
var findNodeDirectory = require('../lib/find-node-directory')
'use strict'
var platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix']
const test = require('tap').test
const path = require('path')
const findNodeDirectory = require('../lib/find-node-directory')
const platforms = [ 'darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix' ]
// we should find the directory based on the directory

@@ -14,6 +16,6 @@ // the script is running in and it should match the layout

for (var next = 0; next < platforms.length; next++) {
var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]}
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(
findNodeDirectory('/x/deps/npm/node_modules/node-gyp/lib', processObj),
path.join('/x'))
path.join('/x'))
}

@@ -30,11 +32,11 @@ })

for (var next = 0; next < platforms.length; next++) {
var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]}
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
if (platforms[next] === 'win32') {
t.equal(
findNodeDirectory('/y/node_modules/npm/node_modules/node-gyp/lib',
processObj), path.join('/y'))
processObj), path.join('/y'))
} else {
t.equal(
findNodeDirectory('/y/lib/node_modules/npm/node_modules/node-gyp/lib',
processObj), path.join('/y'))
processObj), path.join('/y'))
}

@@ -49,3 +51,3 @@ }

for (var next = 0; next < platforms.length; next++) {
var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]}
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(

@@ -64,6 +66,6 @@ findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),

if (platforms[next] === 'win32') {
processObj = {execPath: '/x/y/Release/node', platform: platforms[next]}
processObj = { execPath: '/x/y/Release/node', platform: platforms[next] }
} else {
processObj = {execPath: '/x/y/out/Release/node',
platform: platforms[next]}
processObj = { execPath: '/x/y/out/Release/node',
platform: platforms[next] }
}

@@ -73,3 +75,3 @@

findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/x/y'))
path.join('/x/y'))
}

@@ -85,5 +87,5 @@ })

if (platforms[next] === 'win32') {
processObj = {execPath: '/a/b/Debug/node', platform: platforms[next]}
processObj = { execPath: '/a/b/Debug/node', platform: platforms[next] }
} else {
processObj = {execPath: '/a/b/out/Debug/node', platform: platforms[next]}
processObj = { execPath: '/a/b/out/Debug/node', platform: platforms[next] }
}

@@ -93,3 +95,3 @@

findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/a/b'))
path.join('/a/b'))
}

@@ -103,3 +105,3 @@ })

for (var next = 0; next < platforms.length; next++) {
var processObj = {execPath: '/x/y/z/y', platform:next}
var processObj = { execPath: '/x/y/z/y', platform: next }
t.equal(findNodeDirectory('/a/b/c/d', processObj), '')

@@ -118,7 +120,7 @@ }

for (var next = 0; next < platforms.length; next++) {
var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]}
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(
findNodeDirectory('/x/y/z/a/b/c/deps/npm/node_modules/node-gyp/lib',
processObj), path.join('/x/y/z/a/b/c'))
processObj), path.join('/x/y/z/a/b/c'))
}
})
'use strict'
var test = require('tap').test
var configure = require('../lib/configure')
var execFile = require('child_process').execFile
var PythonFinder = configure.test.PythonFinder
const test = require('tap').test
const findPython = require('../lib/find-python')
const execFile = require('child_process').execFile
const PythonFinder = findPython.test.PythonFinder
delete process.env.PYTHON
delete process.env.NODE_GYP_FORCE_PYTHON
require('npmlog').level = 'warn'

@@ -13,3 +16,3 @@

configure.test.findPython(null, function (err, found) {
findPython.test.findPython(null, function (err, found) {
t.strictEqual(err, null)

@@ -26,4 +29,4 @@ var proc = execFile(found, ['-V'], function (err, stdout, stderr) {

function poison(object, property) {
function fail() {
function poison (object, property) {
function fail () {
console.error(Error(`Property ${property} should not have been accessed.`))

@@ -36,3 +39,3 @@ process.abort()

get: fail,
set: fail,
set: fail
}

@@ -42,3 +45,5 @@ Object.defineProperty(object, property, descriptor)

function TestPythonFinder() { PythonFinder.apply(this, arguments) }
function TestPythonFinder () {
PythonFinder.apply(this, arguments)
}
TestPythonFinder.prototype = Object.create(PythonFinder.prototype)

@@ -51,3 +56,3 @@ // Silence npmlog - remove for debugging

warn: () => {},
error: () => {},
error: () => {}
}

@@ -59,4 +64,4 @@

var f = new TestPythonFinder('python', done)
f.execFile = function(program, args, opts, cb) {
f.execFile = function(program, args, opts, cb) {
f.execFile = function (program, args, opts, cb) {
f.execFile = function (program, args, opts, cb) {
poison(f, 'execFile')

@@ -68,3 +73,3 @@ t.strictEqual(program, '/path/python')

t.strictEqual(program,
process.platform === 'win32' ? '"python"' : 'python')
process.platform === 'win32' ? '"python"' : 'python')
t.ok(/sys\.executable/.test(args[1]))

@@ -75,3 +80,3 @@ cb(null, '/path/python')

function done(err, python) {
function done (err, python) {
t.strictEqual(err, null)

@@ -86,6 +91,6 @@ t.strictEqual(python, '/path/python')

var f = new TestPythonFinder(null, done)
f.execFile = function(program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length-1])) {
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(null, '/path/python')
} else if (/sys\.version_info/.test(args[args.length-1])) {
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(null, '2.3.4')

@@ -98,3 +103,3 @@ } else {

function done(err) {
function done (err) {
t.ok(/Could not find any Python/.test(err))

@@ -105,23 +110,2 @@ t.ok(/not supported/i.test(f.errorLog))

test('find python - python too new', function (t) {
t.plan(2)
var f = new TestPythonFinder(null, done)
f.execFile = function(program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length-1])) {
cb(null, '/path/python')
} else if (/sys\.version_info/.test(args[args.length-1])) {
cb(null, '3.0.0')
} else {
t.fail()
}
}
f.findPython()
function done(err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not supported/i.test(f.errorLog))
}
})
test('find python - no python', function (t) {

@@ -131,6 +115,6 @@ t.plan(2)

var f = new TestPythonFinder(null, done)
f.execFile = function(program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length-1])) {
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else if (/sys\.version_info/.test(args[args.length-1])) {
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(new Error('not a Python executable'))

@@ -143,3 +127,3 @@ } else {

function done(err) {
function done (err) {
t.ok(/Could not find any Python/.test(err))

@@ -150,27 +134,2 @@ t.ok(/not in PATH/.test(f.errorLog))

test('find python - no python2', function (t) {
t.plan(2)
var f = new TestPythonFinder(null, done)
f.execFile = function(program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length-1])) {
if (program == 'python2') {
cb(new Error('not found'))
} else {
cb(null, '/path/python')
}
} else if (/sys\.version_info/.test(args[args.length-1])) {
cb(null, '2.7.14')
} else {
t.fail()
}
}
f.findPython()
function done(err, python) {
t.strictEqual(err, null)
t.strictEqual(python, '/path/python')
}
})
test('find python - no python2, no python, unix', function (t) {

@@ -183,4 +142,4 @@ t.plan(2)

f.execFile = function(program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length-1])) {
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))

@@ -193,3 +152,3 @@ } else {

function done(err) {
function done (err) {
t.ok(/Could not find any Python/.test(err))

@@ -206,3 +165,3 @@ t.ok(/not in PATH/.test(f.errorLog))

f.execFile = function(program, args, opts, cb) {
f.execFile = function (program, args, opts, cb) {
if (program === 'py.exe') {

@@ -213,5 +172,5 @@ t.notEqual(args.indexOf('-2'), -1)

}
if (/sys\.executable/.test(args[args.length-1])) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else if (/sys\.version_info/.test(args[args.length-1])) {
} else if (/sys\.version_info/.test(args[args.length - 1])) {
if (program === 'Z:\\snake.exe') {

@@ -228,3 +187,3 @@ cb(null, '2.7.14')

function done(err, python) {
function done (err, python) {
t.strictEqual(err, null)

@@ -235,97 +194,15 @@ t.strictEqual(python, 'Z:\\snake.exe')

test('find python - python 3, use python launcher', function (t) {
t.plan(4)
var f = new TestPythonFinder(null, done)
f.win = true
f.execFile = function(program, args, opts, cb) {
if (program === 'py.exe') {
f.execFile = function(program, args, opts, cb) {
poison(f, 'execFile')
if (/sys\.version_info/.test(args[args.length-1])) {
cb(null, '2.7.14')
} else {
t.fail()
}
}
t.notEqual(args.indexOf('-2'), -1)
t.notEqual(args.indexOf('-c'), -1)
return cb(null, 'Z:\\snake.exe')
}
if (/sys\.executable/.test(args[args.length-1])) {
cb(null, '/path/python')
} else if (/sys\.version_info/.test(args[args.length-1])) {
cb(null, '3.0.0')
} else {
t.fail()
}
}
f.findPython()
function done(err, python) {
t.strictEqual(err, null)
t.strictEqual(python, 'Z:\\snake.exe')
}
})
test('find python - python 3, use python launcher, python 2 too old',
function (t) {
t.plan(6)
var f = new TestPythonFinder(null, done)
f.win = true
f.execFile = function(program, args, opts, cb) {
if (program === 'py.exe') {
f.execFile = function(program, args, opts, cb) {
if (/sys\.version_info/.test(args[args.length-1])) {
f.execFile = function(program, args, opts, cb) {
if (/sys\.version_info/.test(args[args.length-1])) {
poison(f, 'execFile')
t.strictEqual(program, f.defaultLocation)
cb(new Error('not found'))
} else {
t.fail()
}
}
t.strictEqual(program, 'Z:\\snake.exe')
cb(null, '2.3.4')
} else {
t.fail()
}
}
t.notEqual(args.indexOf('-2'), -1)
t.notEqual(args.indexOf('-c'), -1)
return cb(null, 'Z:\\snake.exe')
}
if (/sys\.executable/.test(args[args.length-1])) {
cb(null, '/path/python')
} else if (/sys\.version_info/.test(args[args.length-1])) {
cb(null, '3.0.0')
} else {
t.fail()
}
}
f.findPython()
function done(err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not supported/i.test(f.errorLog))
}
})
test('find python - no python, no python launcher, good guess', function (t) {
t.plan(4)
var re = /C:[\\\/]Python27[\\\/]python[.]exe/
var re = /C:[\\/]Python27[\\/]python[.]exe/
var f = new TestPythonFinder(null, done)
f.win = true
f.execFile = function(program, args, opts, cb) {
f.execFile = function (program, args, opts, cb) {
if (program === 'py.exe') {
f.execFile = function(program, args, opts, cb) {
f.execFile = function (program, args, opts, cb) {
poison(f, 'execFile')
t.ok(re.test(program))
t.ok(/sys\.version_info/.test(args[args.length-1]))
t.ok(/sys\.version_info/.test(args[args.length - 1]))
cb(null, '2.7.14')

@@ -335,3 +212,3 @@ }

}
if (/sys\.executable/.test(args[args.length-1])) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))

@@ -344,3 +221,3 @@ } else {

function done(err, python) {
function done (err, python) {
t.strictEqual(err, null)

@@ -357,6 +234,6 @@ t.ok(re.test(python))

f.execFile = function(program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length-1])) {
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else if (/sys\.version_info/.test(args[args.length-1])) {
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(new Error('not a Python executable'))

@@ -369,3 +246,3 @@ } else {

function done(err) {
function done (err) {
t.ok(/Could not find any Python/.test(err))

@@ -372,0 +249,0 @@ t.ok(/not in PATH/.test(f.errorLog))

'use strict'
var test = require('tap').test
const test = require('tap').test
const fs = require('fs')

@@ -528,3 +528,3 @@ const path = require('path')

test('look for VS2017 by installation path', function (t) {
test('look for VS2019 by installation path', function (t) {
t.plan(2)

@@ -544,2 +544,17 @@

test('msvs_version match should be case insensitive', function (t) {
t.plan(2)
const finder = new TestVisualStudioFinder(semverV1,
'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS',
(err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path,
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
})
allVsVersions(t, finder)
finder.findVisualStudio()
})
test('latest version should be found by default', function (t) {

@@ -573,2 +588,18 @@ t.plan(2)

test('VCINSTALLDIR match should be case insensitive', function (t) {
t.plan(2)
process.env.VCINSTALLDIR =
'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS\\VC'
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path,
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
})
allVsVersions(t, finder)
finder.findVisualStudio()
})
test('run on a unusable VS Command Prompt', function (t) {

@@ -575,0 +606,0 @@ t.plan(2)

'use strict'
var test = require('tap').test
var install = require('../lib/install').test.install
const test = require('tap').test
const install = require('../lib/install').test.install

@@ -16,3 +16,3 @@ require('npmlog').level = 'error' // we expect a warning

cb(err)
t.ok(true);
t.ok(true)
}

@@ -19,0 +19,0 @@

@@ -1,5 +0,5 @@

'use strict';
'use strict'
var test = require('tap').test
var gyp = require('../lib/node-gyp')
const test = require('tap').test
const gyp = require('../lib/node-gyp')

@@ -11,4 +11,4 @@ test('options in environment', function (t) {

Object.keys(process.env)
.filter(function(key) { return /^npm_config_/.test(key) })
.forEach(function(key) { delete process.env[key] })
.filter(function (key) { return /^npm_config_/.test(key) })
.forEach(function (key) { delete process.env[key] })

@@ -22,6 +22,6 @@ // Zero-length keys should get filtered out.

var g = gyp();
g.parseArgv(['rebuild']) // Also sets opts.argv.
var g = gyp()
g.parseArgv(['rebuild']) // Also sets opts.argv.
t.deepEqual(Object.keys(g.opts).sort(), ['argv', 'x'])
})

@@ -1,4 +0,6 @@

var test = require('tap').test
var processRelease = require('../lib/process-release')
'use strict'
const test = require('tap').test
const processRelease = require('../lib/process-release')
test('test process release - process.version = 0.8.20', function (t) {

@@ -20,3 +22,3 @@ t.plan(2)

ia32: { libUrl: 'https://nodejs.org/dist/v0.8.20/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.8.20/x64/node.lib', libPath: 'x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.8.20/x64/node.lib', libPath: 'x64/node.lib' }
})

@@ -41,3 +43,3 @@ })

ia32: { libUrl: 'https://nodejs.org/dist/v0.10.21/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.21/x64/node.lib', libPath: 'x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.21/x64/node.lib', libPath: 'x64/node.lib' }
})

@@ -63,3 +65,3 @@ })

ia32: { libUrl: 'https://nodejs.org/dist/v0.12.9/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.12.9/x64/node.lib', libPath: 'x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.12.9/x64/node.lib', libPath: 'x64/node.lib' }
})

@@ -85,3 +87,3 @@ })

ia32: { libUrl: 'https://nodejs.org/dist/v0.10.41/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.41/x64/node.lib', libPath: 'x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.41/x64/node.lib', libPath: 'x64/node.lib' }
})

@@ -107,3 +109,3 @@ })

ia32: { libUrl: 'https://nodejs.org/dist/v0.10.42/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.42/x64/node.lib', libPath: 'x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.42/x64/node.lib', libPath: 'x64/node.lib' }
})

@@ -129,3 +131,3 @@ })

ia32: { libUrl: 'https://nodejs.org/dist/v0.12.10/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.12.10/x64/node.lib', libPath: 'x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.12.10/x64/node.lib', libPath: 'x64/node.lib' }
})

@@ -153,3 +155,3 @@ })

ia32: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }
})

@@ -177,3 +179,3 @@ })

ia32: { libUrl: 'https://some.custom.location/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://some.custom.location/win-x64/node.lib', libPath: 'win-x64/node.lib' },
x64: { libUrl: 'https://some.custom.location/win-x64/node.lib', libPath: 'win-x64/node.lib' }
})

@@ -201,3 +203,3 @@ })

ia32: { libUrl: 'https://nodejs.org/dist/v0.10.40/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.40/x64/node.lib', libPath: 'x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.40/x64/node.lib', libPath: 'x64/node.lib' }
})

@@ -225,3 +227,3 @@ })

ia32: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' },
x64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }
})

@@ -249,7 +251,6 @@ })

ia32: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x86/frankenstein.lib', libPath: 'win-x86/frankenstein.lib' },
x64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' },
x64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' }
})
})
test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=http://foo.bar/baz/', function (t) {

@@ -274,3 +275,3 @@ t.plan(2)

ia32: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x86/frankenstein.lib', libPath: 'win-x86/frankenstein.lib' },
x64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' },
x64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' }
})

@@ -298,7 +299,6 @@ })

ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }
})
})
test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]', function (t) {

@@ -325,7 +325,6 @@ t.plan(2)

ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }
})
})
test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string passed as argv[0]', function (t) {

@@ -352,3 +351,3 @@ t.plan(2)

ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }
})

@@ -378,3 +377,3 @@ })

ia32: { libUrl: 'http://foo.bar/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'http://foo.bar/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' },
x64: { libUrl: 'http://foo.bar/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }
})

@@ -381,0 +380,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