aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/node-gyp/lib
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/node-gyp/lib')
-rw-r--r--deps/npm/node_modules/node-gyp/lib/Find-VS2017.cs271
-rw-r--r--deps/npm/node_modules/node-gyp/lib/build.js266
-rw-r--r--deps/npm/node_modules/node-gyp/lib/clean.js22
-rw-r--r--deps/npm/node_modules/node-gyp/lib/configure.js523
-rw-r--r--deps/npm/node_modules/node-gyp/lib/find-node-directory.js61
-rw-r--r--deps/npm/node_modules/node-gyp/lib/find-vs2017.js46
-rw-r--r--deps/npm/node_modules/node-gyp/lib/install.js469
-rw-r--r--deps/npm/node_modules/node-gyp/lib/list.js33
-rw-r--r--deps/npm/node_modules/node-gyp/lib/node-gyp.js215
-rw-r--r--deps/npm/node_modules/node-gyp/lib/process-release.js155
-rw-r--r--deps/npm/node_modules/node-gyp/lib/rebuild.js14
-rw-r--r--deps/npm/node_modules/node-gyp/lib/remove.js52
12 files changed, 2127 insertions, 0 deletions
diff --git a/deps/npm/node_modules/node-gyp/lib/Find-VS2017.cs b/deps/npm/node_modules/node-gyp/lib/Find-VS2017.cs
new file mode 100644
index 0000000000..87e0a9c9bb
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/Find-VS2017.cs
@@ -0,0 +1,271 @@
+// Copyright 2017 - Refael Ackermann
+// Distributed under MIT style license
+// See accompanying file LICENSE at https://github.com/node4good/windows-autoconf
+
+// Usage:
+// powershell -ExecutionPolicy Unrestricted -Version "2.0" -Command "&{Add-Type -Path Find-VS2017.cs; [VisualStudioConfiguration.Main]::Query()}"
+using System;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace VisualStudioConfiguration
+{
+ [Flags]
+ public enum InstanceState : uint
+ {
+ None = 0,
+ Local = 1,
+ Registered = 2,
+ NoRebootRequired = 4,
+ NoErrors = 8,
+ Complete = 4294967295,
+ }
+
+ [Guid("6380BCFF-41D3-4B2E-8B2E-BF8A6810C848")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [ComImport]
+ public interface IEnumSetupInstances
+ {
+
+ void Next([MarshalAs(UnmanagedType.U4), In] int celt,
+ [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface), Out] ISetupInstance[] rgelt,
+ [MarshalAs(UnmanagedType.U4)] out int pceltFetched);
+
+ void Skip([MarshalAs(UnmanagedType.U4), In] int celt);
+
+ void Reset();
+
+ [return: MarshalAs(UnmanagedType.Interface)]
+ IEnumSetupInstances Clone();
+ }
+
+ [Guid("42843719-DB4C-46C2-8E7C-64F1816EFD5B")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [ComImport]
+ public interface ISetupConfiguration
+ {
+ }
+
+ [Guid("26AAB78C-4A60-49D6-AF3B-3C35BC93365D")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [ComImport]
+ public interface ISetupConfiguration2 : ISetupConfiguration
+ {
+
+ [return: MarshalAs(UnmanagedType.Interface)]
+ IEnumSetupInstances EnumInstances();
+
+ [return: MarshalAs(UnmanagedType.Interface)]
+ ISetupInstance GetInstanceForCurrentProcess();
+
+ [return: MarshalAs(UnmanagedType.Interface)]
+ ISetupInstance GetInstanceForPath([MarshalAs(UnmanagedType.LPWStr), In] string path);
+
+ [return: MarshalAs(UnmanagedType.Interface)]
+ IEnumSetupInstances EnumAllInstances();
+ }
+
+ [Guid("B41463C3-8866-43B5-BC33-2B0676F7F42E")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [ComImport]
+ public interface ISetupInstance
+ {
+ }
+
+ [Guid("89143C9A-05AF-49B0-B717-72E218A2185C")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [ComImport]
+ public interface ISetupInstance2 : ISetupInstance
+ {
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetInstanceId();
+
+ [return: MarshalAs(UnmanagedType.Struct)]
+ System.Runtime.InteropServices.ComTypes.FILETIME GetInstallDate();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetInstallationName();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetInstallationPath();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetInstallationVersion();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetDisplayName([MarshalAs(UnmanagedType.U4), In] int lcid);
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetDescription([MarshalAs(UnmanagedType.U4), In] int lcid);
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string ResolvePath([MarshalAs(UnmanagedType.LPWStr), In] string pwszRelativePath);
+
+ [return: MarshalAs(UnmanagedType.U4)]
+ InstanceState GetState();
+
+ [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)]
+ ISetupPackageReference[] GetPackages();
+
+ ISetupPackageReference GetProduct();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetProductPath();
+
+ [return: MarshalAs(UnmanagedType.VariantBool)]
+ bool IsLaunchable();
+
+ [return: MarshalAs(UnmanagedType.VariantBool)]
+ bool IsComplete();
+
+ [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)]
+ ISetupPropertyStore GetProperties();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetEnginePath();
+ }
+
+ [Guid("DA8D8A16-B2B6-4487-A2F1-594CCCCD6BF5")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [ComImport]
+ public interface ISetupPackageReference
+ {
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetId();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetVersion();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetChip();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetLanguage();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetBranch();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetType();
+
+ [return: MarshalAs(UnmanagedType.BStr)]
+ string GetUniqueId();
+
+ [return: MarshalAs(UnmanagedType.VariantBool)]
+ bool GetIsExtension();
+ }
+
+ [Guid("c601c175-a3be-44bc-91f6-4568d230fc83")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [ComImport]
+ public interface ISetupPropertyStore
+ {
+
+ [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
+ string[] GetNames();
+
+ object GetValue([MarshalAs(UnmanagedType.LPWStr), In] string pwszName);
+ }
+
+ [Guid("42843719-DB4C-46C2-8E7C-64F1816EFD5B")]
+ [CoClass(typeof(SetupConfigurationClass))]
+ [ComImport]
+ public interface SetupConfiguration : ISetupConfiguration2, ISetupConfiguration
+ {
+ }
+
+ [Guid("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D")]
+ [ClassInterface(ClassInterfaceType.None)]
+ [ComImport]
+ public class SetupConfigurationClass
+ {
+ }
+
+ public static class Main
+ {
+ public static void Query()
+ {
+ ISetupConfiguration query = new SetupConfiguration();
+ ISetupConfiguration2 query2 = (ISetupConfiguration2)query;
+ IEnumSetupInstances e = query2.EnumAllInstances();
+
+ int pceltFetched;
+ ISetupInstance2[] rgelt = new ISetupInstance2[1];
+ StringBuilder log = new StringBuilder();
+ while (true)
+ {
+ e.Next(1, rgelt, out pceltFetched);
+ if (pceltFetched <= 0)
+ {
+ Console.WriteLine(String.Format("{{\"log\":\"{0}\"}}", log.ToString()));
+ return;
+ }
+ if (CheckInstance(rgelt[0], ref log))
+ return;
+ }
+ }
+
+ private static bool CheckInstance(ISetupInstance2 setupInstance2, ref StringBuilder log)
+ {
+ // Visual Studio Community 2017 component directory:
+ // https://www.visualstudio.com/en-us/productinfo/vs2017-install-product-Community.workloads
+
+ string path = setupInstance2.GetInstallationPath().Replace("\\", "\\\\");
+ log.Append(String.Format("Found installation at: {0}\\n", path));
+
+ bool hasMSBuild = false;
+ bool hasVCTools = false;
+ uint Win10SDKVer = 0;
+ bool hasWin8SDK = false;
+
+ foreach (ISetupPackageReference package in setupInstance2.GetPackages())
+ {
+ const string Win10SDKPrefix = "Microsoft.VisualStudio.Component.Windows10SDK.";
+
+ string id = package.GetId();
+ if (id == "Microsoft.VisualStudio.VC.MSBuild.Base")
+ hasMSBuild = true;
+ else if (id == "Microsoft.VisualStudio.Component.VC.Tools.x86.x64")
+ hasVCTools = true;
+ else if (id.StartsWith(Win10SDKPrefix)) {
+ string[] parts = id.Substring(Win10SDKPrefix.Length).Split('.');
+ if (parts.Length > 1 && parts[1] != "Desktop")
+ continue;
+ Win10SDKVer = Math.Max(Win10SDKVer, UInt32.Parse(parts[0]));
+ } else if (id == "Microsoft.VisualStudio.Component.Windows81SDK")
+ hasWin8SDK = true;
+ else
+ continue;
+
+ log.Append(String.Format(" - Found {0}\\n", id));
+ }
+
+ if (!hasMSBuild)
+ log.Append(" - Missing Visual Studio C++ core features (Microsoft.VisualStudio.VC.MSBuild.Base)\\n");
+ if (!hasVCTools)
+ log.Append(" - Missing VC++ 2017 v141 toolset (x86,x64) (Microsoft.VisualStudio.Component.VC.Tools.x86.x64)\\n");
+ if ((Win10SDKVer == 0) && (!hasWin8SDK))
+ log.Append(" - Missing a Windows SDK (Microsoft.VisualStudio.Component.Windows10SDK.* or Microsoft.VisualStudio.Component.Windows81SDK)\\n");
+
+ if (hasMSBuild && hasVCTools)
+ {
+ if (Win10SDKVer > 0)
+ {
+ log.Append(" - Using this installation with Windows 10 SDK"/*\\n*/);
+ Console.WriteLine(String.Format("{{\"log\":\"{0}\",\"path\":\"{1}\",\"sdk\":\"10.0.{2}.0\"}}", log.ToString(), path, Win10SDKVer));
+ return true;
+ }
+ else if (hasWin8SDK)
+ {
+ log.Append(" - Using this installation with Windows 8.1 SDK"/*\\n*/);
+ Console.WriteLine(String.Format("{{\"log\":\"{0}\",\"path\":\"{1}\",\"sdk\":\"8.1\"}}", log.ToString(), path));
+ return true;
+ }
+ }
+
+ log.Append(" - Some required components are missing, not using this installation\\n");
+ return false;
+ }
+ }
+}
diff --git a/deps/npm/node_modules/node-gyp/lib/build.js b/deps/npm/node_modules/node-gyp/lib/build.js
new file mode 100644
index 0000000000..0445fb6452
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/build.js
@@ -0,0 +1,266 @@
+
+module.exports = exports = build
+
+/**
+ * Module dependencies.
+ */
+
+var fs = require('graceful-fs')
+ , rm = require('rimraf')
+ , path = require('path')
+ , glob = require('glob')
+ , log = require('npmlog')
+ , which = require('which')
+ , exec = require('child_process').exec
+ , processRelease = require('./process-release')
+ , win = process.platform === 'win32'
+
+exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module'
+
+function build (gyp, argv, callback) {
+ var platformMake = 'make'
+ if (process.platform === 'aix') {
+ platformMake = 'gmake'
+ } else if (process.platform.indexOf('bsd') !== -1) {
+ platformMake = 'gmake'
+ }
+
+ var release = processRelease(argv, gyp, process.version, process.release)
+ , makeCommand = gyp.opts.make || process.env.MAKE || platformMake
+ , command = win ? 'msbuild' : makeCommand
+ , buildDir = path.resolve('build')
+ , configPath = path.resolve(buildDir, 'config.gypi')
+ , jobs = gyp.opts.jobs || process.env.JOBS
+ , buildType
+ , config
+ , arch
+ , nodeDir
+
+ loadConfigGypi()
+
+ /**
+ * Load the "config.gypi" file that was generated during "configure".
+ */
+
+ function loadConfigGypi () {
+ fs.readFile(configPath, 'utf8', function (err, data) {
+ if (err) {
+ if (err.code == 'ENOENT') {
+ callback(new Error('You must run `node-gyp configure` first!'))
+ } else {
+ callback(err)
+ }
+ return
+ }
+ config = JSON.parse(data.replace(/\#.+\n/, ''))
+
+ // get the 'arch', 'buildType', and 'nodeDir' vars from the config
+ buildType = config.target_defaults.default_configuration
+ arch = config.variables.target_arch
+ nodeDir = config.variables.nodedir
+
+ if ('debug' in gyp.opts) {
+ buildType = gyp.opts.debug ? 'Debug' : 'Release'
+ }
+ if (!buildType) {
+ buildType = 'Release'
+ }
+
+ log.verbose('build type', buildType)
+ log.verbose('architecture', arch)
+ log.verbose('node dev dir', nodeDir)
+
+ if (win) {
+ findSolutionFile()
+ } else {
+ doWhich()
+ }
+ })
+ }
+
+ /**
+ * On Windows, find the first build/*.sln file.
+ */
+
+ function findSolutionFile () {
+ glob('build/*.sln', function (err, files) {
+ if (err) return callback(err)
+ if (files.length === 0) {
+ return callback(new Error('Could not find *.sln file. Did you run "configure"?'))
+ }
+ guessedSolution = files[0]
+ log.verbose('found first Solution file', guessedSolution)
+ doWhich()
+ })
+ }
+
+ /**
+ * Uses node-which to locate the msbuild / make executable.
+ */
+
+ function doWhich () {
+ // First make sure we have the build command in the PATH
+ which(command, function (err, execPath) {
+ if (err) {
+ if (win && /not found/.test(err.message)) {
+ // On windows and no 'msbuild' found. Let's guess where it is
+ findMsbuild()
+ } else {
+ // Some other error or 'make' not found on Unix, report that to the user
+ callback(err)
+ }
+ return
+ }
+ log.verbose('`which` succeeded for `' + command + '`', execPath)
+ doBuild()
+ })
+ }
+
+ /**
+ * Search for the location of "msbuild.exe" file on Windows.
+ */
+
+ function findMsbuild () {
+ if (config.variables.msbuild_path) {
+ command = config.variables.msbuild_path
+ log.verbose('using MSBuild:', command)
+ doBuild()
+ return
+ }
+
+ log.verbose('could not find "msbuild.exe" in PATH - finding location in registry')
+ var notfoundErr = 'Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?'
+ var cmd = 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s'
+ if (process.arch !== 'ia32')
+ cmd += ' /reg:32'
+ exec(cmd, function (err, stdout, stderr) {
+ if (err) {
+ return callback(new Error(err.message + '\n' + notfoundErr))
+ }
+ var reVers = /ToolsVersions\\([^\\]+)$/i
+ , rePath = /\r\n[ \t]+MSBuildToolsPath[ \t]+REG_SZ[ \t]+([^\r]+)/i
+ , msbuilds = []
+ , r
+ , msbuildPath
+ stdout.split('\r\n\r\n').forEach(function(l) {
+ if (!l) return
+ l = l.trim()
+ if (r = reVers.exec(l.substring(0, l.indexOf('\r\n')))) {
+ var ver = parseFloat(r[1], 10)
+ if (ver >= 3.5) {
+ if (r = rePath.exec(l)) {
+ msbuilds.push({
+ version: ver,
+ path: r[1]
+ })
+ }
+ }
+ }
+ })
+ msbuilds.sort(function (x, y) {
+ return (x.version < y.version ? -1 : 1)
+ })
+ ;(function verifyMsbuild () {
+ if (!msbuilds.length) return callback(new Error(notfoundErr))
+ msbuildPath = path.resolve(msbuilds.pop().path, 'msbuild.exe')
+ fs.stat(msbuildPath, function (err, stat) {
+ if (err) {
+ if (err.code == 'ENOENT') {
+ if (msbuilds.length) {
+ return verifyMsbuild()
+ } else {
+ callback(new Error(notfoundErr))
+ }
+ } else {
+ callback(err)
+ }
+ return
+ }
+ command = msbuildPath
+ doBuild()
+ })
+ })()
+ })
+ }
+
+
+ /**
+ * Actually spawn the process and compile the module.
+ */
+
+ function doBuild () {
+
+ // Enable Verbose build
+ var verbose = log.levels[log.level] <= log.levels.verbose
+ if (!win && verbose) {
+ argv.push('V=1')
+ }
+ if (win && !verbose) {
+ argv.push('/clp:Verbosity=minimal')
+ }
+
+ if (win) {
+ // Turn off the Microsoft logo on Windows
+ argv.push('/nologo')
+ }
+
+ // Specify the build type, Release by default
+ if (win) {
+ var archLower = arch.toLowerCase()
+ var p = archLower === 'x64' ? 'x64' :
+ (archLower === 'arm' ? 'ARM' : 'Win32')
+ argv.push('/p:Configuration=' + buildType + ';Platform=' + p)
+ if (jobs) {
+ var j = parseInt(jobs, 10)
+ if (!isNaN(j) && j > 0) {
+ argv.push('/m:' + j)
+ } else if (jobs.toUpperCase() === 'MAX') {
+ argv.push('/m:' + require('os').cpus().length)
+ }
+ }
+ } else {
+ argv.push('BUILDTYPE=' + buildType)
+ // Invoke the Makefile in the 'build' dir.
+ argv.push('-C')
+ argv.push('build')
+ if (jobs) {
+ var j = parseInt(jobs, 10)
+ if (!isNaN(j) && j > 0) {
+ argv.push('--jobs')
+ argv.push(j)
+ } else if (jobs.toUpperCase() === 'MAX') {
+ argv.push('--jobs')
+ argv.push(require('os').cpus().length)
+ }
+ }
+ }
+
+ if (win) {
+ // did the user specify their own .sln file?
+ var hasSln = argv.some(function (arg) {
+ return path.extname(arg) == '.sln'
+ })
+ if (!hasSln) {
+ argv.unshift(gyp.opts.solution || guessedSolution)
+ }
+ }
+
+ var proc = gyp.spawn(command, argv)
+ proc.on('exit', onExit)
+ }
+
+ /**
+ * Invoked after the make/msbuild command exits.
+ */
+
+ function onExit (code, signal) {
+ if (code !== 0) {
+ return callback(new Error('`' + command + '` failed with exit code: ' + code))
+ }
+ if (signal) {
+ return callback(new Error('`' + command + '` got signal: ' + signal))
+ }
+ callback()
+ }
+
+}
diff --git a/deps/npm/node_modules/node-gyp/lib/clean.js b/deps/npm/node_modules/node-gyp/lib/clean.js
new file mode 100644
index 0000000000..e69164d45a
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/clean.js
@@ -0,0 +1,22 @@
+
+module.exports = exports = clean
+
+exports.usage = 'Removes any generated build files and the "out" dir'
+
+/**
+ * Module dependencies.
+ */
+
+var rm = require('rimraf')
+var log = require('npmlog')
+
+
+function clean (gyp, argv, callback) {
+
+ // Remove the 'build' dir
+ var buildDir = 'build'
+
+ log.verbose('clean', 'removing "%s" directory', buildDir)
+ rm(buildDir, callback)
+
+}
diff --git a/deps/npm/node_modules/node-gyp/lib/configure.js b/deps/npm/node_modules/node-gyp/lib/configure.js
new file mode 100644
index 0000000000..1351576d12
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/configure.js
@@ -0,0 +1,523 @@
+module.exports = exports = configure
+module.exports.test = {
+ PythonFinder: PythonFinder,
+ findAccessibleSync: findAccessibleSync,
+ findPython: findPython,
+}
+
+/**
+ * Module dependencies.
+ */
+
+var fs = require('graceful-fs')
+ , path = require('path')
+ , log = require('npmlog')
+ , osenv = require('osenv')
+ , which = require('which')
+ , 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
+if (win)
+ var findVS2017 = require('./find-vs2017')
+
+exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module'
+
+function configure (gyp, argv, callback) {
+
+ var python = gyp.opts.python || process.env.PYTHON || 'python2'
+ , buildDir = path.resolve('build')
+ , configNames = [ 'config.gypi', 'common.gypi' ]
+ , configs = []
+ , nodeDir
+ , release = processRelease(argv, gyp, process.version, process.release)
+
+ findPython(python, function (err, found) {
+ if (err) {
+ callback(err)
+ } else {
+ python = found
+ getNodeDir()
+ }
+ })
+
+ function getNodeDir () {
+
+ // 'python' should be set by now
+ process.env.PYTHON = python
+
+ if (gyp.opts.nodedir) {
+ // --nodedir was specified. use that for the dev files
+ nodeDir = gyp.opts.nodedir.replace(/^~/, osenv.home())
+
+ log.verbose('get node dir', 'compiling against specified --nodedir dev files: %s', nodeDir)
+ createBuildDir()
+
+ } else {
+ // if no --nodedir specified, ensure node dependencies are installed
+ if ('v' + release.version !== process.version) {
+ // if --target was given, then determine a target version to compile for
+ 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
+ log.verbose('get node dir', 'no --target version specified, falling back to host node version: %s', release.version)
+ }
+
+ if (!release.semver) {
+ // could not parse the version string with semver
+ return callback(new Error('Invalid version number: ' + release.version))
+ }
+
+ // ensure that the target node version's dev files are installed
+ gyp.opts.ensure = true
+ gyp.commands.install([ release.version ], function (err, version) {
+ if (err) return callback(err)
+ log.verbose('get node dir', 'target node version installed:', release.versionDir)
+ nodeDir = path.resolve(gyp.devDir, release.versionDir)
+ createBuildDir()
+ })
+ }
+ }
+
+ function createBuildDir () {
+ log.verbose('build dir', 'attempting to create "build" dir: %s', buildDir)
+ mkdirp(buildDir, function (err, isNew) {
+ if (err) return callback(err)
+ log.verbose('build dir', '"build" dir needed to be created?', isNew)
+ if (win && (!gyp.opts.msvs_version || gyp.opts.msvs_version === '2017')) {
+ findVS2017(function (err, vsSetup) {
+ if (err) {
+ log.verbose('Not using VS2017:', err.message)
+ createConfigFile()
+ } else {
+ createConfigFile(null, vsSetup)
+ }
+ })
+ } else {
+ createConfigFile()
+ }
+ })
+ }
+
+ function createConfigFile (err, vsSetup) {
+ if (err) return callback(err)
+
+ var configFilename = 'config.gypi'
+ var configPath = path.resolve(buildDir, configFilename)
+
+ log.verbose('build/' + configFilename, 'creating config file')
+
+ var config = process.config || {}
+ , defaults = config.target_defaults
+ , variables = config.variables
+
+ // default "config.variables"
+ if (!variables) variables = config.variables = {}
+
+ // default "config.defaults"
+ if (!defaults) defaults = config.target_defaults = {}
+
+ // don't inherit the "defaults" from node's `process.config` object.
+ // doing so could cause problems in cases where the `node` executable was
+ // compiled on a different machine (with different lib/include paths) than
+ // the machine where the addon is being built to
+ defaults.cflags = []
+ defaults.defines = []
+ defaults.include_dirs = []
+ defaults.libraries = []
+
+ // set the default_configuration prop
+ if ('debug' in gyp.opts) {
+ defaults.default_configuration = gyp.opts.debug ? 'Debug' : 'Release'
+ }
+ if (!defaults.default_configuration) {
+ defaults.default_configuration = 'Release'
+ }
+
+ // set the target_arch variable
+ variables.target_arch = gyp.opts.arch || process.arch || 'ia32'
+
+ // set the node development directory
+ variables.nodedir = nodeDir
+
+ // disable -T "thin" static archives by default
+ variables.standalone_static_library = gyp.opts.thin ? 0 : 1
+
+ if (vsSetup) {
+ // GYP doesn't (yet) have support for VS2017, so we force it to VS2015
+ // to avoid pulling a floating patch that has not landed upstream.
+ // Ref: https://chromium-review.googlesource.com/#/c/433540/
+ gyp.opts.msvs_version = '2015'
+ process.env['GYP_MSVS_VERSION'] = 2015
+ process.env['GYP_MSVS_OVERRIDE_PATH'] = vsSetup.path
+ defaults['msbuild_toolset'] = 'v141'
+ defaults['msvs_windows_target_platform_version'] = vsSetup.sdk
+ variables['msbuild_path'] = path.join(vsSetup.path, 'MSBuild', '15.0',
+ 'Bin', 'MSBuild.exe')
+ }
+
+ // loop through the rest of the opts and add the unknown ones as variables.
+ // this allows for module-specific configure flags like:
+ //
+ // $ node-gyp configure --shared-libxml2
+ Object.keys(gyp.opts).forEach(function (opt) {
+ if (opt === 'argv') return
+ if (opt in gyp.configDefs) return
+ variables[opt.replace(/-/g, '_')] = gyp.opts[opt]
+ })
+
+ // ensures that any boolean values from `process.config` get stringified
+ function boolsToString (k, v) {
+ if (typeof v === 'boolean')
+ return String(v)
+ return v
+ }
+
+ log.silly('build/' + configFilename, config)
+
+ // now write out the config.gypi file to the build/ dir
+ var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step'
+ , 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)
+ }
+
+ function findConfigs (err) {
+ if (err) return callback(err)
+ var name = configNames.shift()
+ if (!name) return runGyp()
+ var fullPath = path.resolve(name)
+ log.verbose(name, 'checking for gypi file: %s', fullPath)
+ fs.stat(fullPath, function (err, stat) {
+ if (err) {
+ if (err.code == 'ENOENT') {
+ findConfigs() // check next gypi filename
+ } else {
+ callback(err)
+ }
+ } else {
+ log.verbose(name, 'found gypi file')
+ configs.push(fullPath)
+ findConfigs()
+ }
+ })
+ }
+
+ function runGyp (err) {
+ if (err) return callback(err)
+
+ if (!~argv.indexOf('-f') && !~argv.indexOf('--format')) {
+ if (win) {
+ log.verbose('gyp', 'gyp format was not specified; forcing "msvs"')
+ // force the 'make' target for non-Windows
+ argv.push('-f', 'msvs')
+ } else {
+ log.verbose('gyp', 'gyp format was not specified; forcing "make"')
+ // force the 'make' target for non-Windows
+ argv.push('-f', 'make')
+ }
+ }
+
+ function hasMsvsVersion () {
+ return argv.some(function (arg) {
+ return arg.indexOf('msvs_version') === 0
+ })
+ }
+
+ if (win && !hasMsvsVersion()) {
+ if ('msvs_version' in gyp.opts) {
+ argv.push('-G', 'msvs_version=' + gyp.opts.msvs_version)
+ } else {
+ argv.push('-G', 'msvs_version=auto')
+ }
+ }
+
+ // include all the ".gypi" files that were found
+ configs.forEach(function (config) {
+ argv.push('-I', config)
+ })
+
+ // for AIX we need to set up the path to the exp file
+ // which contains the symbols needed for linking.
+ // The file will either be in one of the following
+ // depending on whether it is an installed or
+ // development environment:
+ // - the include/node directory
+ // - the out/Release directory
+ // - the out/Debug directory
+ // - the root directory
+ var node_exp_file = undefined
+ if (process.platform === 'aix') {
+ var node_root_dir = findNodeDirectory()
+ var candidates = ['include/node/node.exp',
+ 'out/Release/node.exp',
+ 'out/Debug/node.exp',
+ 'node.exp']
+ 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)
+ } else {
+ var msg = msgFormat('Could not find node.exp file in %s', node_root_dir)
+ log.error(logprefix, 'Could not find exports file')
+ 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, stat) {
+ if (err)
+ 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 nodeLibFile = path.join(nodeDir,
+ !gyp.opts.nodedir ? '<(target_arch)' : '$(Configuration)',
+ release.name + '.lib')
+
+ 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)
+ if (process.platform === 'aix') {
+ argv.push('-Dnode_exp_file=' + node_exp_file)
+ }
+ argv.push('-Dnode_gyp_dir=' + nodeGypDir)
+ argv.push('-Dnode_lib_file=' + nodeLibFile)
+ argv.push('-Dmodule_root_dir=' + process.cwd())
+ argv.push('-Dnode_engine=' +
+ (gyp.opts.node_engine || process.jsEngine || 'v8'))
+ argv.push('--depth=.')
+ argv.push('--no-parallel')
+
+ // tell gyp to write the Makefile/Solution files into output_dir
+ argv.push('--generator-output', output_dir)
+
+ // tell make to write its output into the same dir
+ argv.push('-Goutput_dir=.')
+
+ // enforce use of the "binding.gyp" file
+ argv.unshift('binding.gyp')
+
+ // execute `gyp` from the current target nodedir
+ argv.unshift(gyp_script)
+
+ // make sure python uses files that came with this particular node package
+ var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')]
+ if (process.env.PYTHONPATH) {
+ pypath.push(process.env.PYTHONPATH)
+ }
+ process.env.PYTHONPATH = pypath.join(win ? ';' : ':')
+
+ var cp = gyp.spawn(python, argv)
+ cp.on('exit', onCpExit)
+ })
+ }
+
+ /**
+ * Called when the `gyp` child process exits.
+ */
+
+ function onCpExit (code, signal) {
+ if (code !== 0) {
+ callback(new Error('`gyp` failed with exit code: ' + code))
+ } else {
+ // we're done
+ callback()
+ }
+ }
+
+}
+
+/**
+ * Returns the first file or directory from an array of candidates that is
+ * readable by the current user, or undefined if none of the candidates are
+ * readable.
+ */
+function findAccessibleSync (logprefix, dir, candidates) {
+ 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
+ }
+
+ return undefined
+}
+
+function PythonFinder(python, callback) {
+ this.callback = callback
+ this.python = python
+}
+
+PythonFinder.prototype = {
+ checkPythonLauncherDepth: 0,
+ env: process.env,
+ execFile: cp.execFile,
+ log: log,
+ resolve: path.win32 && path.win32.resolve || path.resolve,
+ stat: fs.stat,
+ which: which,
+ win: win,
+
+ checkPython: function checkPython () {
+ this.log.verbose('check python',
+ 'checking for Python executable "%s" in the PATH',
+ this.python)
+ this.which(this.python, function (err, execPath) {
+ if (err) {
+ this.log.verbose('`which` failed', this.python, err)
+ if (this.python === 'python2') {
+ this.python = 'python'
+ return this.checkPython()
+ }
+ if (this.win) {
+ this.checkPythonLauncher()
+ } else {
+ this.failNoPython()
+ }
+ } else {
+ this.log.verbose('`which` succeeded', this.python, execPath)
+ // Found the `python` executable, and from now on we use it explicitly.
+ // This solves #667 and #750 (`execFile` won't run batch files
+ // (*.cmd, and *.bat))
+ this.python = execPath
+ this.checkPythonVersion()
+ }
+ }.bind(this))
+ },
+
+ // 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.
+ checkPythonLauncher: function checkPythonLauncher () {
+ this.checkPythonLauncherDepth += 1
+
+ this.log.verbose(
+ 'could not find "' + this.python + '". checking python launcher')
+ var env = extend({}, this.env)
+ env.TERM = 'dumb'
+
+ var launcherArgs = ['-2', '-c', 'import sys; print sys.executable']
+ this.execFile('py.exe', launcherArgs, { env: env }, function (err, stdout) {
+ if (err) {
+ this.guessPython()
+ } else {
+ this.python = stdout.trim()
+ this.log.verbose('check python launcher',
+ 'python executable found: %j',
+ this.python)
+ this.checkPythonVersion()
+ }
+ this.checkPythonLauncherDepth -= 1
+ }.bind(this))
+ },
+
+ checkPythonVersion: function checkPythonVersion () {
+ var args = ['-c', 'import platform; print(platform.python_version());']
+ var env = extend({}, this.env)
+ env.TERM = 'dumb'
+
+ this.execFile(this.python, args, { env: env }, function (err, stdout) {
+ if (err) {
+ return this.callback(err)
+ }
+ this.log.verbose('check python version',
+ '`%s -c "' + args[1] + '"` returned: %j',
+ this.python, stdout)
+ var version = stdout.trim()
+ if (~version.indexOf('+')) {
+ this.log.silly('stripping "+" sign(s) from version')
+ version = version.replace(/\+/g, '')
+ }
+ if (~version.indexOf('rc')) {
+ this.log.silly('stripping "rc" identifier from version')
+ version = version.replace(/rc(.*)$/ig, '')
+ }
+ var range = semver.Range('>=2.5.0 <3.0.0')
+ var valid = false
+ try {
+ valid = range.test(version)
+ } catch (e) {
+ this.log.silly('range.test() error', e)
+ }
+ if (valid) {
+ this.callback(null, this.python)
+ } else if (this.win && this.checkPythonLauncherDepth === 0) {
+ this.checkPythonLauncher()
+ } else {
+ this.failPythonVersion(version)
+ }
+ }.bind(this))
+ },
+
+ failNoPython: function failNoPython () {
+ var errmsg =
+ 'Can\'t find Python executable "' + this.python +
+ '", you can set the PYTHON env variable.'
+ this.callback(new Error(errmsg))
+ },
+
+ failPythonVersion: function failPythonVersion (badVersion) {
+ var errmsg =
+ 'Python executable "' + this.python +
+ '" is v' + badVersion + ', which is not supported by gyp.\n' +
+ 'You can pass the --python switch to point to ' +
+ 'Python >= v2.5.0 & < 3.0.0.'
+ this.callback(new Error(errmsg))
+ },
+
+ // Called on Windows when "python" isn't available in the current $PATH.
+ // We are going to check if "%SystemDrive%\python27\python.exe" exists.
+ guessPython: function guessPython () {
+ this.log.verbose('could not find "' + this.python + '". guessing location')
+ var rootDir = this.env.SystemDrive || 'C:\\'
+ if (rootDir[rootDir.length - 1] !== '\\') {
+ rootDir += '\\'
+ }
+ var pythonPath = this.resolve(rootDir, 'Python27', 'python.exe')
+ this.log.verbose('ensuring that file exists:', pythonPath)
+ this.stat(pythonPath, function (err, stat) {
+ if (err) {
+ if (err.code == 'ENOENT') {
+ this.failNoPython()
+ } else {
+ this.callback(err)
+ }
+ return
+ }
+ this.python = pythonPath
+ this.checkPythonVersion()
+ }.bind(this))
+ },
+}
+
+function findPython (python, callback) {
+ var finder = new PythonFinder(python, callback)
+ finder.checkPython()
+}
diff --git a/deps/npm/node_modules/node-gyp/lib/find-node-directory.js b/deps/npm/node_modules/node-gyp/lib/find-node-directory.js
new file mode 100644
index 0000000000..3aee8a109a
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/find-node-directory.js
@@ -0,0 +1,61 @@
+var path = require('path')
+ , log = require('npmlog')
+
+function findNodeDirectory(scriptLocation, processObj) {
+ // set dirname and process if not passed in
+ // this facilitates regression tests
+ if (scriptLocation === undefined) {
+ scriptLocation = __dirname
+ }
+ if (processObj === undefined) {
+ processObj = process
+ }
+
+ // 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 = ""
+
+ log.verbose('node-gyp root', 'Finding node root directory')
+ if (path.basename(npm_parent_directory) === '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') {
+ // We are in a node install directory where this script lives in
+ // lib/node_modules/npm/node_modules/node-gyp/lib or
+ // node_modules/npm/node_modules/node-gyp/lib depending on the
+ // platform
+ if (processObj.platform === 'win32') {
+ node_root_dir = path.join(npm_parent_directory, '..')
+ } else {
+ node_root_dir = path.join(npm_parent_directory, '../..')
+ }
+ log.verbose('node-gyp root', 'in install directory, root = '
+ + node_root_dir)
+ } 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') {
+ // If we are a recently built node, and the directory structure
+ // is that of a repository. If we are on Windows then we only need
+ // to go one level up, everything else, two
+ if (processObj.platform === 'win32') {
+ node_root_dir = path.join(node_dir, '..')
+ } else {
+ node_root_dir = path.join(node_dir, '../..')
+ }
+ }
+ // Else return the default blank, "".
+ }
+ return node_root_dir
+}
+
+module.exports = findNodeDirectory
diff --git a/deps/npm/node_modules/node-gyp/lib/find-vs2017.js b/deps/npm/node_modules/node-gyp/lib/find-vs2017.js
new file mode 100644
index 0000000000..8c79e9ec9b
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/find-vs2017.js
@@ -0,0 +1,46 @@
+var log = require('npmlog')
+ , execFile = require('child_process').execFile
+ , path = require('path')
+
+function findVS2017(callback) {
+ var ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell',
+ 'v1.0', 'powershell.exe')
+ var csFile = path.join(__dirname, 'Find-VS2017.cs')
+ var psArgs = ['-ExecutionPolicy', 'Unrestricted', '-Command',
+ '&{Add-Type -Path \'' + csFile +
+ '\'; [VisualStudioConfiguration.Main]::Query()}']
+
+ log.silly('find vs2017', 'Running', ps, psArgs)
+ var child = execFile(ps, psArgs, { encoding: 'utf8' },
+ function (err, stdout, stderr) {
+ log.silly('find vs2017', 'PS err:', err)
+ log.silly('find vs2017', 'PS stdout:', stdout)
+ log.silly('find vs2017', 'PS stderr:', stderr)
+
+ if (err)
+ return callback(new Error('Could not use PowerShell to find VS2017'))
+
+ var vsSetup
+ try {
+ vsSetup = JSON.parse(stdout)
+ } catch (e) {
+ log.silly('find vs2017', e)
+ return callback(new Error('Could not use PowerShell to find VS2017'))
+ }
+ log.silly('find vs2017', 'vsSetup:', vsSetup)
+
+ if (vsSetup && vsSetup.log)
+ log.verbose('find vs2017', vsSetup.log.trimRight())
+
+ if (!vsSetup || !vsSetup.path || !vsSetup.sdk) {
+ return callback(new Error('No usable installation of VS2017 found'))
+ }
+
+ log.verbose('find vs2017', 'using installation:', vsSetup.path)
+ callback(null, { "path": vsSetup.path, "sdk": vsSetup.sdk })
+ })
+
+ child.stdin.end()
+}
+
+module.exports = findVS2017
diff --git a/deps/npm/node_modules/node-gyp/lib/install.js b/deps/npm/node_modules/node-gyp/lib/install.js
new file mode 100644
index 0000000000..fa2e1c5430
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/install.js
@@ -0,0 +1,469 @@
+
+module.exports = exports = install
+
+module.exports.test = { download: download, readCAFile: readCAFile }
+
+exports.usage = 'Install node development files for the specified node version.'
+
+/**
+ * Module dependencies.
+ */
+
+var fs = require('graceful-fs')
+ , osenv = require('osenv')
+ , tar = require('tar')
+ , rm = require('rimraf')
+ , path = require('path')
+ , crypto = require('crypto')
+ , zlib = require('zlib')
+ , log = require('npmlog')
+ , semver = require('semver')
+ , fstream = require('fstream')
+ , request = require('request')
+ , minimatch = require('minimatch')
+ , mkdir = require('mkdirp')
+ , processRelease = require('./process-release')
+ , win = process.platform == 'win32'
+
+function install (gyp, argv, callback) {
+
+ var release = processRelease(argv, gyp, process.version, process.release)
+
+ // ensure no double-callbacks happen
+ function cb (err) {
+ if (cb.done) return
+ cb.done = true
+ if (err) {
+ log.warn('install', 'got an error, rolling back install')
+ // roll-back the install if anything went wrong
+ gyp.commands.remove([ release.versionDir ], function (err2) {
+ callback(err)
+ })
+ } else {
+ callback(null, release.version)
+ }
+ }
+
+ // Determine which node dev files version we are installing
+ log.verbose('install', 'input version string %j', release.version)
+
+ if (!release.semver) {
+ // could not parse the version string with semver
+ return callback(new Error('Invalid version number: ' + release.version))
+ }
+
+ 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 (release.semver.prerelease[0] === 'pre') {
+ log.verbose('detected "pre" node version', release.version)
+ if (gyp.opts.nodedir) {
+ log.verbose('--nodedir flag was passed; skipping install', gyp.opts.nodedir)
+ callback()
+ } else {
+ callback(new Error('"pre" versions of node cannot be installed, use the --nodedir flag instead'))
+ }
+ return
+ }
+
+ // flatten version into String
+ log.verbose('install', 'installing version: %s', release.versionDir)
+
+ // the directory where the dev files will be installed
+ var devDir = path.resolve(gyp.devDir, release.versionDir)
+
+ // If '--ensure' was passed, then don't *always* install the version;
+ // check if it is already installed, and only install when needed
+ if (gyp.opts.ensure) {
+ log.verbose('install', '--ensure was passed, so won\'t reinstall if already installed')
+ fs.stat(devDir, function (err, stat) {
+ if (err) {
+ if (err.code == 'ENOENT') {
+ log.verbose('install', 'version not already installed, continuing with install', release.version)
+ go()
+ } else if (err.code == 'EACCES') {
+ eaccesFallback()
+ } else {
+ cb(err)
+ }
+ return
+ }
+ log.verbose('install', 'version is already installed, need to check "installVersion"')
+ var installVersionFile = path.resolve(devDir, 'installVersion')
+ fs.readFile(installVersionFile, 'ascii', function (err, ver) {
+ if (err && err.code != 'ENOENT') {
+ return cb(err)
+ }
+ var installVersion = parseInt(ver, 10) || 0
+ log.verbose('got "installVersion"', installVersion)
+ log.verbose('needs "installVersion"', gyp.package.installVersion)
+ if (installVersion < gyp.package.installVersion) {
+ log.verbose('install', 'version is no good; reinstalling')
+ go()
+ } else {
+ log.verbose('install', 'version is good')
+ cb()
+ }
+ })
+ })
+ } else {
+ go()
+ }
+
+ function getContentSha(res, callback) {
+ var shasum = crypto.createHash('sha256')
+ res.on('data', function (chunk) {
+ shasum.update(chunk)
+ }).on('end', function () {
+ callback(null, shasum.digest('hex'))
+ })
+ }
+
+ function go () {
+
+ log.verbose('ensuring nodedir is created', devDir)
+
+ // first create the dir for the node dev files
+ mkdir(devDir, function (err, created) {
+ if (err) {
+ if (err.code == 'EACCES') {
+ eaccesFallback()
+ } else {
+ cb(err)
+ }
+ return
+ }
+
+ if (created) {
+ log.verbose('created nodedir', created)
+ }
+
+ // now download the node tarball
+ var tarPath = gyp.opts.tarball
+ var badDownload = false
+ , extractCount = 0
+ , gunzip = zlib.createGunzip()
+ , extracter = tar.Extract({ path: devDir, strip: 1, filter: isValid })
+
+ var contentShasums = {}
+ var expectShasums = {}
+
+ // checks if a file to be extracted from the tarball is valid.
+ // only .h header files and the gyp files get extracted
+ function isValid () {
+ var name = this.path.substring(devDir.length + 1)
+ var isValid = valid(name)
+ if (name === '' && this.type === 'Directory') {
+ // the first directory entry is ok
+ return true
+ }
+ if (isValid) {
+ log.verbose('extracted file from tarball', name)
+ extractCount++
+ } else {
+ // invalid
+ log.silly('ignoring from tarball', name)
+ }
+ return isValid
+ }
+
+ gunzip.on('error', cb)
+ extracter.on('error', cb)
+ extracter.on('end', afterTarball)
+
+ // download the tarball, gunzip and extract!
+
+ if (tarPath) {
+ var input = fs.createReadStream(tarPath)
+ input.pipe(gunzip).pipe(extracter)
+ return
+ }
+
+ try {
+ var req = download(gyp, process.env, release.tarballUrl)
+ } catch (e) {
+ return cb(e)
+ }
+
+ // something went wrong downloading the tarball?
+ req.on('error', function (err) {
+ if (err.code === 'ENOTFOUND') {
+ return cb(new Error('This is most likely not a problem with node-gyp or the package itself and\n' +
+ 'is related to network connectivity. In most cases you are behind a proxy or have bad \n' +
+ 'network settings.'))
+ }
+ badDownload = true
+ cb(err)
+ })
+
+ req.on('close', function () {
+ if (extractCount === 0) {
+ cb(new Error('Connection closed while downloading tarball file'))
+ }
+ })
+
+ req.on('response', function (res) {
+ if (res.statusCode !== 200) {
+ badDownload = true
+ cb(new Error(res.statusCode + ' response downloading ' + release.tarballUrl))
+ return
+ }
+ // content checksum
+ getContentSha(res, function (_, checksum) {
+ var filename = path.basename(release.tarballUrl).trim()
+ contentShasums[filename] = checksum
+ log.verbose('content checksum', filename, checksum)
+ })
+
+ // start unzipping and untaring
+ req.pipe(gunzip).pipe(extracter)
+ })
+
+ // invoked after the tarball has finished being extracted
+ function afterTarball () {
+ if (badDownload) return
+ if (extractCount === 0) {
+ return cb(new Error('There was a fatal problem while downloading/extracting the tarball'))
+ }
+ log.verbose('tarball', 'done parsing tarball')
+ var async = 0
+
+ if (win) {
+ // need to download node.lib
+ async++
+ downloadNodeLib(deref)
+ }
+
+ // write the "installVersion" file
+ async++
+ var installVersionPath = path.resolve(devDir, 'installVersion')
+ fs.writeFile(installVersionPath, gyp.package.installVersion + '\n', deref)
+
+ // Only download SHASUMS.txt if not using tarPath override
+ if (!tarPath) {
+ // download SHASUMS.txt
+ async++
+ downloadShasums(deref)
+ }
+
+ if (async === 0) {
+ // no async tasks required
+ cb()
+ }
+
+ function deref (err) {
+ if (err) return cb(err)
+
+ async--
+ if (!async) {
+ log.verbose('download contents checksum', JSON.stringify(contentShasums))
+ // check content shasums
+ for (var k in contentShasums) {
+ log.verbose('validating download checksum for ' + k, '(%s == %s)', contentShasums[k], expectShasums[k])
+ if (contentShasums[k] !== expectShasums[k]) {
+ cb(new Error(k + ' local checksum ' + contentShasums[k] + ' not match remote ' + expectShasums[k]))
+ return
+ }
+ }
+ cb()
+ }
+ }
+ }
+
+ function downloadShasums(done) {
+ log.verbose('check download content checksum, need to download `SHASUMS256.txt`...')
+ var shasumsPath = path.resolve(devDir, 'SHASUMS256.txt')
+
+ log.verbose('checksum url', release.shasumsUrl)
+ try {
+ var req = download(gyp, process.env, release.shasumsUrl)
+ } catch (e) {
+ return cb(e)
+ }
+
+ req.on('error', done)
+ req.on('response', function (res) {
+ if (res.statusCode !== 200) {
+ done(new Error(res.statusCode + ' status code downloading checksum'))
+ return
+ }
+
+ var chunks = []
+ res.on('data', function (chunk) {
+ chunks.push(chunk)
+ })
+ res.on('end', function () {
+ var lines = Buffer.concat(chunks).toString().trim().split('\n')
+ lines.forEach(function (line) {
+ var items = line.trim().split(/\s+/)
+ if (items.length !== 2) return
+
+ // 0035d18e2dcf9aad669b1c7c07319e17abfe3762 ./node-v0.11.4.tar.gz
+ var name = items[1].replace(/^\.\//, '')
+ expectShasums[name] = items[0]
+ })
+
+ log.verbose('checksum data', JSON.stringify(expectShasums))
+ done()
+ })
+ })
+ }
+
+ function downloadNodeLib (done) {
+ log.verbose('on Windows; need to download `' + release.name + '.lib`...')
+ var dir32 = path.resolve(devDir, 'ia32')
+ , dir64 = path.resolve(devDir, 'x64')
+ , libPath32 = path.resolve(dir32, release.name + '.lib')
+ , libPath64 = path.resolve(dir64, release.name + '.lib')
+
+ 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)
+
+ var async = 2
+ mkdir(dir32, function (err) {
+ if (err) return done(err)
+ log.verbose('streaming 32-bit ' + release.name + '.lib to:', libPath32)
+
+ try {
+ var req = download(gyp, process.env, release.libUrl32, cb)
+ } catch (e) {
+ return cb(e)
+ }
+
+ req.on('error', done)
+ req.on('response', function (res) {
+ if (res.statusCode !== 200) {
+ done(new Error(res.statusCode + ' status code downloading 32-bit ' + release.name + '.lib'))
+ return
+ }
+
+ getContentSha(res, function (_, checksum) {
+ contentShasums[release.libPath32] = checksum
+ log.verbose('content checksum', release.libPath32, checksum)
+ })
+
+ var ws = fs.createWriteStream(libPath32)
+ ws.on('error', cb)
+ req.pipe(ws)
+ })
+ req.on('end', function () {
+ --async || done()
+ })
+ })
+ mkdir(dir64, function (err) {
+ if (err) return done(err)
+ log.verbose('streaming 64-bit ' + release.name + '.lib to:', libPath64)
+
+ try {
+ var req = download(gyp, process.env, release.libUrl64, cb)
+ } catch (e) {
+ return cb(e)
+ }
+
+ req.on('error', done)
+ req.on('response', function (res) {
+ if (res.statusCode !== 200) {
+ done(new Error(res.statusCode + ' status code downloading 64-bit ' + release.name + '.lib'))
+ return
+ }
+
+ getContentSha(res, function (_, checksum) {
+ contentShasums[release.libPath64] = checksum
+ log.verbose('content checksum', release.libPath64, checksum)
+ })
+
+ var ws = fs.createWriteStream(libPath64)
+ ws.on('error', cb)
+ req.pipe(ws)
+ })
+ req.on('end', function () {
+ --async || done()
+ })
+ })
+ } // downloadNodeLib()
+
+ }) // mkdir()
+
+ } // go()
+
+ /**
+ * Checks if a given filename is "valid" for this installation.
+ */
+
+ function valid (file) {
+ // header files
+ return minimatch(file, '*.h', { matchBase: true }) ||
+ minimatch(file, '*.gypi', { matchBase: true })
+ }
+
+ /**
+ * The EACCES fallback is a workaround for npm's `sudo` behavior, where
+ * it drops the permissions before invoking any child processes (like
+ * node-gyp). So what happens is the "nobody" user doesn't have
+ * permission to create the dev dir. As a fallback, make the tmpdir() be
+ * the dev dir for this installation. This is not ideal, but at least
+ * the compilation will succeed...
+ */
+
+ function eaccesFallback () {
+ var tmpdir = osenv.tmpdir()
+ gyp.devDir = path.resolve(tmpdir, '.node-gyp')
+ log.warn('EACCES', 'user "%s" does not have permission to access the dev dir "%s"', osenv.user(), devDir)
+ log.warn('EACCES', 'attempting to reinstall using temporary dev dir "%s"', gyp.devDir)
+ if (process.cwd() == tmpdir) {
+ log.verbose('tmpdir == cwd', 'automatically will remove dev files after to save disk space')
+ gyp.todo.push({ name: 'remove', args: argv })
+ }
+ gyp.commands.install(argv, cb)
+ }
+
+}
+
+function download (gyp, env, url) {
+ log.http('GET', url)
+
+ var requestOpts = {
+ uri: url
+ , headers: {
+ 'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')'
+ }
+ }
+
+ var cafile = gyp.opts.cafile
+ if (cafile) {
+ requestOpts.ca = readCAFile(cafile)
+ }
+
+ // basic support for a proxy server
+ var proxyUrl = gyp.opts.proxy
+ || env.http_proxy
+ || env.HTTP_PROXY
+ || env.npm_config_proxy
+ if (proxyUrl) {
+ if (/^https?:\/\//i.test(proxyUrl)) {
+ log.verbose('download', 'using proxy url: "%s"', proxyUrl)
+ requestOpts.proxy = proxyUrl
+ } else {
+ log.warn('download', 'ignoring invalid "proxy" config setting: "%s"', proxyUrl)
+ }
+ }
+
+ var req = request(requestOpts)
+ req.on('response', function (res) {
+ log.http(res.statusCode, url)
+ })
+
+ return req
+}
+
+function readCAFile (filename) {
+ // The CA file can contain multiple certificates so split on certificate
+ // boundaries. [\S\s]*? is used to match everything including newlines.
+ var ca = fs.readFileSync(filename, 'utf8')
+ var re = /(-----BEGIN CERTIFICATE-----[\S\s]*?-----END CERTIFICATE-----)/g
+ return ca.match(re)
+}
diff --git a/deps/npm/node_modules/node-gyp/lib/list.js b/deps/npm/node_modules/node-gyp/lib/list.js
new file mode 100644
index 0000000000..9d680a56a4
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/list.js
@@ -0,0 +1,33 @@
+
+module.exports = exports = list
+
+exports.usage = 'Prints a listing of the currently installed node development files'
+
+/**
+ * Module dependencies.
+ */
+
+var fs = require('graceful-fs')
+ , path = require('path')
+ , log = require('npmlog')
+
+function list (gyp, args, callback) {
+
+ var devDir = gyp.devDir
+ log.verbose('list', 'using node-gyp dir:', devDir)
+
+ // readdir() the node-gyp dir
+ fs.readdir(devDir, onreaddir)
+
+ function onreaddir (err, versions) {
+ if (err && err.code != 'ENOENT') {
+ return callback(err)
+ }
+ if (Array.isArray(versions)) {
+ versions = versions.filter(function (v) { return v != 'current' })
+ } else {
+ versions = []
+ }
+ callback(null, versions)
+ }
+}
diff --git a/deps/npm/node_modules/node-gyp/lib/node-gyp.js b/deps/npm/node_modules/node-gyp/lib/node-gyp.js
new file mode 100644
index 0000000000..0dcea7298f
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/node-gyp.js
@@ -0,0 +1,215 @@
+
+/**
+ * Module exports.
+ */
+
+module.exports = exports = gyp
+
+/**
+ * Module dependencies.
+ */
+
+var fs = require('graceful-fs')
+ , 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
+log.heading = 'gyp'
+
+/**
+ * The `gyp` function.
+ */
+
+function gyp () {
+ return new Gyp()
+}
+
+function Gyp () {
+ var self = this
+
+ this.devDir = ''
+ this.commands = {}
+
+ commands.forEach(function (command) {
+ self.commands[command] = function (argv, callback) {
+ log.verbose('command', command, argv)
+ return require('./' + command)(self, argv, callback)
+ }
+ })
+}
+inherits(Gyp, EE)
+exports.Gyp = Gyp
+var proto = Gyp.prototype
+
+/**
+ * Export the contents of the package.json.
+ */
+
+proto.package = require('../package')
+
+/**
+ * nopt configuration definitions
+ */
+
+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'
+}
+
+/**
+ * nopt shorthands
+ */
+
+proto.shorthands = {
+ release: '--no-debug'
+ , C: '--directory'
+ , debug: '--debug'
+ , j: '--jobs'
+ , silly: '--loglevel=silly'
+ , verbose: '--loglevel=verbose'
+ , silent: '--loglevel=silent'
+}
+
+/**
+ * expose the command aliases for the bin file to use.
+ */
+
+proto.aliases = aliases
+
+/**
+ * Parses the given argv array and sets the 'opts',
+ * 'argv' and 'command' properties.
+ */
+
+proto.parseArgv = function parseOpts (argv) {
+ this.opts = nopt(this.configDefs, this.shorthands, argv)
+ this.argv = this.opts.argv.remain.slice()
+
+ var commands = this.todo = []
+
+ // create a copy of the argv array with aliases mapped
+ argv = this.argv.map(function (arg) {
+ // is this an alias?
+ if (arg in this.aliases) {
+ arg = this.aliases[arg]
+ }
+ return arg
+ }, this)
+
+ // process the mapped args into "command" objects ("name" and "args" props)
+ argv.slice().forEach(function (arg) {
+ if (arg in this.commands) {
+ var args = argv.splice(0, argv.indexOf(arg))
+ argv.shift()
+ if (commands.length > 0) {
+ commands[commands.length - 1].args = args
+ }
+ commands.push({ name: arg, args: [] })
+ }
+ }, this)
+ if (commands.length > 0) {
+ commands[commands.length - 1].args = argv.splice(0)
+ }
+
+ // support for inheriting config env variables from npm
+ var npm_config_prefix = 'npm_config_'
+ Object.keys(process.env).forEach(function (name) {
+ if (name.indexOf(npm_config_prefix) !== 0) return
+ var val = process.env[name]
+ if (name === npm_config_prefix + 'loglevel') {
+ log.level = val
+ } else {
+ // add the user-defined options to the config
+ name = name.substring(npm_config_prefix.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
+ }
+ }, this)
+
+ if (this.opts.loglevel) {
+ log.level = this.opts.loglevel
+ }
+ log.resume()
+}
+
+/**
+ * Spawns a child process and emits a 'spawn' event.
+ */
+
+proto.spawn = function spawn (command, args, opts) {
+ if (!opts) opts = {}
+ if (!opts.silent && !opts.stdio) {
+ opts.stdio = [ 0, 1, 2 ]
+ }
+ var cp = child_process.spawn(command, args, opts)
+ log.info('spawn', command)
+ log.info('spawn args', args)
+ return cp
+}
+
+/**
+ * Returns the usage instructions for node-gyp.
+ */
+
+proto.usage = function usage () {
+ 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
+ ].join('\n')
+ return str
+}
+
+/**
+ * Version number getter.
+ */
+
+Object.defineProperty(proto, 'version', {
+ get: function () {
+ return this.package.version
+ }
+ , enumerable: true
+})
diff --git a/deps/npm/node_modules/node-gyp/lib/process-release.js b/deps/npm/node_modules/node-gyp/lib/process-release.js
new file mode 100644
index 0000000000..f9ba98f199
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/process-release.js
@@ -0,0 +1,155 @@
+var semver = require('semver')
+ , url = require('url')
+ , path = require('path')
+ , log = require('npmlog')
+
+ // 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"
+
+// Captures all the logic required to determine download URLs, local directory and
+// file names. Inputs come from command-line switches (--target, --dist-url),
+// `process.version` and `process.release` where it exists.
+function processRelease (argv, gyp, defaultVersion, defaultRelease) {
+ var version = (semver.valid(argv[0]) && argv[0]) || gyp.opts.target || defaultVersion
+ , versionSemver = semver.parse(version)
+ , overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl
+ , isDefaultVersion
+ , isIojs
+ , name
+ , distBaseUrl
+ , baseUrl
+ , libUrl32
+ , libUrl64
+ , tarballUrl
+ , canGetHeaders
+
+ if (!versionSemver) {
+ // not a valid semver string, nothing we can do
+ return { version: version }
+ }
+ // flatten version into String
+ version = versionSemver.version
+
+ // defaultVersion should come from process.version so ought to be valid semver
+ isDefaultVersion = version === semver.parse(defaultVersion).version
+
+ // can't use process.release if we're using --target=x.y.z
+ if (!isDefaultVersion)
+ defaultRelease = null
+
+ if (defaultRelease) {
+ // v3 onward, has process.release
+ name = defaultRelease.name.replace(/io\.js/, 'iojs') // remove the '.' for directory naming purposes
+ isIojs = name === 'iojs'
+ } else {
+ // old node or alternative --target=
+ // semver.satisfies() doesn't like prerelease tags so test major directly
+ isIojs = versionSemver.major >= 1 && versionSemver.major < 4
+ name = isIojs ? 'iojs' : 'node'
+ }
+
+ // check for the nvm.sh standard mirror env variables
+ if (!overrideDistUrl) {
+ if (isIojs) {
+ if (process.env.IOJS_ORG_MIRROR) {
+ overrideDistUrl = process.env.IOJS_ORG_MIRROR
+ } else if (process.env.NVM_IOJS_ORG_MIRROR) {// remove on next semver-major
+ overrideDistUrl = process.env.NVM_IOJS_ORG_MIRROR
+ log.warn('download',
+ 'NVM_IOJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, ' +
+ 'please use IOJS_ORG_MIRROR')
+ }
+ } else {
+ if (process.env.NODEJS_ORG_MIRROR) {
+ overrideDistUrl = process.env.NODEJS_ORG_MIRROR
+ } else if (process.env.NVM_NODEJS_ORG_MIRROR) {// remove on next semver-major
+ overrideDistUrl = process.env.NVM_NODEJS_ORG_MIRROR
+ log.warn('download',
+ 'NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, ' +
+ 'please use NODEJS_ORG_MIRROR')
+ }
+ }
+ }
+
+ if (overrideDistUrl)
+ log.verbose('download', 'using dist-url', overrideDistUrl)
+
+ if (overrideDistUrl)
+ distBaseUrl = overrideDistUrl.replace(/\/+$/, '')
+ else
+ distBaseUrl = isIojs ? 'https://iojs.org/download/release' : 'https://nodejs.org/dist'
+ distBaseUrl += '/v' + version + '/'
+
+ // new style, based on process.release so we have a lot of the data we need
+ if (defaultRelease && defaultRelease.headersUrl && !overrideDistUrl) {
+ baseUrl = url.resolve(defaultRelease.headersUrl, './')
+ libUrl32 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x86', versionSemver.major)
+ libUrl64 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x64', versionSemver.major)
+
+ return {
+ version: version,
+ semver: versionSemver,
+ name: name,
+ baseUrl: baseUrl,
+ tarballUrl: defaultRelease.headersUrl,
+ shasumsUrl: url.resolve(baseUrl, 'SHASUMS256.txt'),
+ versionDir: (name !== 'node' ? name + '-' : '') + version,
+ libUrl32: libUrl32,
+ libUrl64: libUrl64,
+ libPath32: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)),
+ libPath64: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path))
+ }
+ }
+
+ // older versions without process.release are captured here and we have to make
+ // a lot of assumptions, additionally if you --target=x.y.z then we can't use the
+ // current process.release
+
+ baseUrl = distBaseUrl
+ libUrl32 = resolveLibUrl(name, baseUrl, 'x86', versionSemver.major)
+ libUrl64 = resolveLibUrl(name, baseUrl, 'x64', versionSemver.major)
+ // making the bold assumption that anything with a version number >3.0.0 will
+ // have a *-headers.tar.gz file in its dist location, even some frankenstein
+ // custom version
+ canGetHeaders = semver.satisfies(versionSemver, headersTarballRange)
+ tarballUrl = url.resolve(baseUrl, name + '-v' + version + (canGetHeaders ? '-headers' : '') + '.tar.gz')
+
+ return {
+ version: version,
+ semver: versionSemver,
+ name: name,
+ baseUrl: baseUrl,
+ tarballUrl: tarballUrl,
+ shasumsUrl: url.resolve(baseUrl, 'SHASUMS256.txt'),
+ versionDir: (name !== 'node' ? name + '-' : '') + version,
+ libUrl32: libUrl32,
+ libUrl64: libUrl64,
+ libPath32: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)),
+ libPath64: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path))
+ }
+}
+
+function normalizePath (p) {
+ return path.normalize(p).replace(/\\/g, '/')
+}
+
+function resolveLibUrl (name, defaultUrl, arch, versionMajor) {
+ var base = url.resolve(defaultUrl, './')
+ , 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')
+ // prior to io.js@1.0.0 32-bit node.lib lives in /, 64-bit lives in /x64/
+ return url.resolve(base, (arch === 'x64' ? 'x64/' : '') + name + '.lib')
+ }
+
+ // else we have a proper url to a .lib, just make sure it's the right arch
+ return defaultUrl.replace(versionMajor === 3 ? bitsreV3 : bitsre, '/win-' + arch + '/')
+}
+
+module.exports = processRelease
diff --git a/deps/npm/node_modules/node-gyp/lib/rebuild.js b/deps/npm/node_modules/node-gyp/lib/rebuild.js
new file mode 100644
index 0000000000..4c6f472aa7
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/rebuild.js
@@ -0,0 +1,14 @@
+
+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: 'configure', args: argv }
+ , { name: 'build', args: [] }
+ )
+ process.nextTick(callback)
+}
diff --git a/deps/npm/node_modules/node-gyp/lib/remove.js b/deps/npm/node_modules/node-gyp/lib/remove.js
new file mode 100644
index 0000000000..eb80981b88
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/remove.js
@@ -0,0 +1,52 @@
+
+module.exports = exports = remove
+
+exports.usage = 'Removes the node development files for the specified version'
+
+/**
+ * Module dependencies.
+ */
+
+var fs = require('fs')
+ , rm = require('rimraf')
+ , path = require('path')
+ , log = require('npmlog')
+ , semver = require('semver')
+
+function remove (gyp, argv, callback) {
+
+ var devDir = gyp.devDir
+ log.verbose('remove', 'using node-gyp dir:', devDir)
+
+ // get the user-specified version to remove
+ var version = argv[0] || gyp.opts.target
+ log.verbose('remove', 'removing target version:', version)
+
+ if (!version) {
+ return callback(new Error('You must specify a version number to remove. Ex: "' + process.version + '"'))
+ }
+
+ var versionSemver = semver.parse(version)
+ if (versionSemver) {
+ // flatten the version Array into a String
+ version = versionSemver.version
+ }
+
+ var versionPath = path.resolve(gyp.devDir, version)
+ log.verbose('remove', 'removing development files for version:', version)
+
+ // first check if its even installed
+ fs.stat(versionPath, function (err, stat) {
+ if (err) {
+ if (err.code == 'ENOENT') {
+ callback(null, 'version was already uninstalled: ' + version)
+ } else {
+ callback(err)
+ }
+ return
+ }
+ // Go ahead and delete the dir
+ rm(versionPath, callback)
+ })
+
+}