Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

windows-build-tools

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

windows-build-tools - npm Package Compare versions

Comparing version 1.4.2 to 2.0.0

lib/logging.js

17

lib/compatible.js

@@ -5,11 +5,12 @@ 'use strict';

if (process.version === 'v7.1.0') {
var utils = require('./utils');
var _require = require('./logging'),
warn = _require.warn;
utils.warn('--------------------------------------------------------------');
utils.warn('You are running Node v7.1.0, which has a known bug on Windows,');
utils.warn('breaking Node applications using the utils (Powershell/CMD).');
utils.warn('Please upgrade to a newer version or use Node v7.0.0.\n\n');
utils.warn('Visit https://github.com/nodejs/node/issues/9542 for details.\n');
utils.warn('windows-build-tools will now run, but might fail.');
utils.warn('---------------------------------------------------------------');
warn('--------------------------------------------------------------');
warn('You are running Node v7.1.0, which has a known bug on Windows,');
warn('breaking Node applications using the utils (Powershell/CMD).');
warn('Please upgrade to a newer version or use Node v7.0.0.\n\n');
warn('Visit https://github.com/nodejs/node/issues/9542 for details.\n');
warn('windows-build-tools will now run, but might fail.');
warn('---------------------------------------------------------------');
}

@@ -16,0 +17,0 @@

@@ -5,10 +5,9 @@ 'use strict';

var python = {};
var buildTools = {
installerName: 'BuildTools_Full.exe',
installerUrl: 'https://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe',
logName: 'build-tools-log.txt'
installerName: 'vs_BuildTools.exe',
installerUrl: 'https://download.visualstudio.microsoft.com/download/pr/11503713/e64d79b40219aea618ce2fe10ebd5f0d/vs_BuildTools.exe'
};
var python = {};
if (process.arch === 'x64') {

@@ -15,0 +14,0 @@ python = {

@@ -5,4 +5,11 @@ 'use strict';

var utils = require('./utils');
var _require = require('./utils/get-build-tools-installer-path'),
getBuildToolsInstallerPath = _require.getBuildToolsInstallerPath;
var _require2 = require('./utils/get-python-installer-path'),
getPythonInstallerPath = _require2.getPythonInstallerPath;
var _require3 = require('./logging'),
log = _require3.log;
/**

@@ -14,9 +21,11 @@ * Downloads the Visual Studio C++ Build Tools and Python installer to a temporary folder

*/
function download(cb) {
downloadTools(utils.getBuildToolsInstallerPath()).then(function () {
return downloadTools(utils.getPythonInstallerPath());
downloadTools(getBuildToolsInstallerPath()).then(function () {
return downloadTools(getPythonInstallerPath());
}).then(function () {
return cb();
}).catch(function (error) {
return utils.log(error);
return log(error);
});

@@ -56,3 +65,3 @@ }

utils.log('Downloaded ' + installer.fileName + '. Saved to ' + installer.path + '.');
log('Downloaded ' + installer.fileName + '. Saved to ' + installer.path + '.');
resolve(installer.path);

@@ -59,0 +68,0 @@ });

'use strict';
var path = require('path');
var utils = require('./utils');
var _require = require('./utils/execute-child-process'),
executeChildProcess = _require.executeChildProcess;
/**

@@ -14,2 +16,4 @@ * Uses PowerShell to configure the environment for

*/
function setEnvironment(variables) {

@@ -23,5 +27,5 @@ var pythonPath = path.join(variables.python.pythonPath);

return utils.executeChildProcess('powershell.exe', args);
return executeChildProcess('powershell.exe', args);
}
module.exports = setEnvironment;
'use strict';
var path = require('path');
var spawn = require('child_process').spawn;
var debug = require('debug')('windows-build-tools');

@@ -9,5 +7,13 @@ var chalk = require('chalk');

var _require = require('../utils/get-python-installer-path'),
getPythonInstallerPath = _require.getPythonInstallerPath;
var _require2 = require('../utils/get-work-dir'),
getWorkDirectory = _require2.getWorkDirectory;
var _require3 = require('../logging'),
log = _require3.log;
var launchInstaller = require('./launch');
var Tailer = require('./tailer');
var utils = require('../utils');

@@ -24,3 +30,3 @@ var spinner = void 0;

function install(cb) {
utils.log(chalk.green('Starting installation...'));
log(chalk.green('Starting installation...'));

@@ -42,3 +48,3 @@ launchInstaller().then(function () {

utils.log(error);
log(error);
});

@@ -54,4 +60,4 @@ }

function launchSpinner() {
utils.log('Launched installers, now waiting for them to finish.');
utils.log('This will likely take some time - please be patient!');
log('Launched installers, now waiting for them to finish.');
log('This will likely take some time - please be patient!');

@@ -65,13 +71,14 @@ spinner = new Spinner('Waiting for installers... %s');

return new Promise(function (resolve, reject) {
var tailer = new Tailer(utils.getBuildToolsInstallerPath().logPath);
var tailer = new Tailer();
tailer.on('exit', function (result, details) {
debug('build tools tailer exited');
debug('Install: Build tools tailer exited');
if (result === 'error') {
debug('Installer: Tailer found error with installer', details);
reject(err);
reject();
}
if (result === 'success') {
utils.log(chalk.bold.green('Successfully installed Visual Studio Build Tools.'));
log(chalk.bold.green('Successfully installed Visual Studio Build Tools.'));
debug('Installer: Successfully installed Visual Studio Build Tools according to tailer');

@@ -82,5 +89,5 @@ resolve();

if (result === 'failure') {
utils.log(chalk.bold.red('Could not install Visual Studio Build Tools.'));
utils.log('Please find more details in the log files, which can be found at');
utils.log(utils.getWorkDirectory());
log(chalk.bold.red('Could not install Visual Studio Build Tools.'));
log('Please find more details in the log files, which can be found at');
log(getWorkDirectory());
debug('Installer: Failed to install according to tailer');

@@ -98,3 +105,3 @@ resolve();

// The log file for msiexe is utf-16
var tailer = new Tailer(utils.getPythonInstallerPath().logPath, 'ucs2');
var tailer = new Tailer(getPythonInstallerPath().logPath, 'ucs2');

@@ -105,11 +112,11 @@ tailer.on('exit', function (result, details) {

debug('Installer: Tailer found error with installer', details);
reject(err);
reject();
}
if (result === 'success') {
utils.log(chalk.bold.green('Successfully installed Python 2.7'));
log(chalk.bold.green('Successfully installed Python 2.7'));
debug('Installer: Successfully installed Python 2.7 according to tailer');
var variables = {
pythonPath: details || utils.getPythonInstallerPath().targetPath
pythonPath: details || getPythonInstallerPath().targetPath
};

@@ -120,5 +127,5 @@ resolve(variables);

if (result === 'failure') {
utils.log(chalk.bold.red('Could not install Python 2.7.'));
utils.log('Please find more details in the log files, which can be found at');
utils.log(utils.getWorkDirectory());
log(chalk.bold.red('Could not install Python 2.7.'));
log('Please find more details in the log files, which can be found at');
log(getWorkDirectory());
debug('Installer: Failed to install Python 2.7 according to tailer');

@@ -125,0 +132,0 @@ resolve(undefined);

@@ -8,6 +8,14 @@ 'use strict';

var utils = require('../utils');
var installer = utils.getBuildToolsInstallerPath();
var pythonInstaller = utils.getPythonInstallerPath();
var _require = require('../logging'),
log = _require.log;
var _require2 = require('../utils/get-build-tools-installer-path'),
getBuildToolsInstallerPath = _require2.getBuildToolsInstallerPath;
var _require3 = require('../utils/get-python-installer-path'),
getPythonInstallerPath = _require3.getPythonInstallerPath;
var installer = getBuildToolsInstallerPath();
var pythonInstaller = getPythonInstallerPath();
/**

@@ -47,4 +55,4 @@ * Launches the installer, using a PS1 script as a middle-man

} catch (error) {
utils.log(chalk.bold.red('Error: failed while trying to run powershell.exe'));
utils.log('(Hint: Is "%SystemRoot%\\system32\\WindowsPowerShell\\v1.0" in your system path?)');
log(chalk.bold.red('Error: failed while trying to run powershell.exe'));
log('(Hint: Is "%SystemRoot%\\system32\\WindowsPowerShell\\v1.0" in your system path?)');
return reject(error);

@@ -57,5 +65,5 @@ }

if (data.toString().includes('Please restart this script from an administrative PowerShell!')) {
utils.log(chalk.bold.red('Please restart this script from an administrative PowerShell!'));
utils.log('The build tools cannot be installed without administrative rights.');
utils.log('To fix, right-click on PowerShell and run "as Administrator".');
log(chalk.bold.red('Please restart this script from an administrative PowerShell!'));
log('The build tools cannot be installed without administrative rights.');
log('To fix, right-click on PowerShell and run "as Administrator".');

@@ -62,0 +70,0 @@ // Bail out

@@ -11,3 +11,2 @@ 'use strict';

var path = require('path');
var fs = require('fs-extra');

@@ -17,3 +16,4 @@ var debug = require('debug')('windows-build-tools');

var utils = require('../utils');
var _require = require('../utils/find-logfile'),
findVCCLogFile = _require.findVCCLogFile;

@@ -43,3 +43,7 @@ var Tailer = function (_EventEmitter) {

value: function start() {
debug('Tail: Waiting for log file to appear in ' + this.logFile);
if (this.logFile) {
debug('Tail: Waiting for log file to appear in ' + this.logFile);
} else {
debug('Tail: Waiting for log file to appear. Searching in %TEMP%');
}
this.waitForLogFile();

@@ -92,6 +96,8 @@ }

debug('Tail start: Could not read logfile ' + this.logFile + ': ' + err);
return;
}
// Success strings for build tools
if (data.includes('Variable: IsInstalled = 1') || data.includes('Variable: BuildTools_Core_Installed = ') || data.includes('WixBundleInstalled = 1')) {
if (data.includes('Closing installer. Return code: 3010.') || data.includes('Closing installer. Return code: 0.')) {
debug('Tail: Reporting success for VCC Build Tools');
this.stop('success');

@@ -102,3 +108,3 @@ // Success strings for python

var matches = data.match(/Property\(S\): TARGETDIR = (.*)\r\n/);
var pythonPath = undefined;
var pythonPath = void 0;

@@ -108,4 +114,6 @@ if (matches) {

}
debug('Tail: Reporting success for Python');
this.stop('success', pythonPath);
} else if (data.includes('Shutting down, exit code:')) {
} else if (data.includes('Closing installer. Return code:') || data.includes('Shutting down, exit code:')) {
debug('Tail: Reporting failure in ' + this.logFile);
this.stop('failure');

@@ -130,14 +138,37 @@ }

fs.lstat(this.logFile, function (err, stats) {
if (err && err.code === 'ENOENT') {
debug('Tail: waitForFile: still waiting');
setTimeout(_this3.waitForLogFile.bind(_this3), 2000);
} else if (err) {
debug('Tail: waitForFile: Unexpected error', err);
throw new Error(err);
} else {
debug('Tail: waitForFile: Found ' + _this3.logFile);
_this3.tail();
}
});
var handleStillWaiting = function handleStillWaiting() {
debug('Tail: waitForFile: still waiting');
setTimeout(_this3.waitForLogFile.bind(_this3), 2000);
};
var handleKnownPath = function handleKnownPath(logFile) {
fs.lstat(logFile, function (err, stats) {
if (err && err.code === 'ENOENT') {
handleStillWaiting();
} else if (err) {
debug('Tail: waitForFile: Unexpected error', err);
throw new Error(err);
} else {
debug('Tail: waitForFile: Found ' + logFile);
_this3.tail();
}
});
};
// If don't have a logfile, we need to find one. The only one
// we need to find right now is the VCC 2017 logfile.
if (!this.logFile) {
findVCCLogFile().then(function (logFile) {
debug('Tail: LogFile found: ' + logFile);
if (!logFile) {
handleStillWaiting();
} else {
_this3.logFile = logFile;
handleKnownPath(logFile);
}
});
} else {
handleKnownPath(this.logFile);
}
}

@@ -144,0 +175,0 @@ }]);

{
"name": "windows-build-tools",
"version": "1.4.2",
"version": "2.0.0",
"description": "Install C++ Build Tools for Windows using npm",

@@ -50,5 +50,5 @@ "main": "lib/index.js",

"debug": "^3.1.0",
"fs-extra": "^4.0.2",
"fs-extra": "^5.0.0",
"nugget": "^2.0.1"
}
}

@@ -13,4 +13,6 @@ # Windows-Build-Tools

After installation, npm will automatically execute this module, which downloads and installs Visual C++ Build Tools 2015, provided free of charge by Microsoft. These tools are [required to compile popular native modules](https://github.com/nodejs/node-gyp). It will also install Python 2.7, configuring your machine and npm appropriately.
After installation, npm will automatically execute this module, which downloads and installs Visual C++ Build Tools 2017, provided free of charge by Microsoft. These tools are [required to compile popular native modules](https://github.com/nodejs/node-gyp). It will also install Python 2.7, configuring your machine and npm appropriately.
To install the Visual C++ Build Tools 2015 (required for Node 7 and below), please use `windows-build-tools@1.4.2`.
> :bulb: [Windows Vista / 7 only] requires [.NET Framework 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40773) (Currently not installed automatically by this package)

@@ -25,6 +27,5 @@

- Visual C++ build scripts (targeting Windows desktop)
- Microsoft Build Tools 2015 (MSBuild)
- Windows SDK 8.1 (optional, on by default)
- Windows SDK 10 (optional, off by default)
- ATL and MFC (optional, off by default)
- Microsoft Build Tools 2017 (MSBuild)
- Windows SDK 10 (optional, on by default)
- ATL and MFC (optional, on by default)
- C++ Build tools specific command prompts

@@ -50,26 +51,8 @@

## Supplying Parameters to the VCC Build Tools
You can pass additional parameters directly to the VCC Build Tools installer. This tool does not check if the parameters make sense - passing incorrect parameters might break the whole installation. As of January 2017, the following parameters are available:
You can pass additional parameters directly to the VCC Build Tools installer. This tool does not check if the parameters make sense - passing incorrect parameters might break the whole installation. The available parameters [are documented here](https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio).
- `/AdminFile`: <filename> Specifies the installation control file.
- `/CreateAdminFile`: <filename> Specifies the location to create a control file that can then be used
- `/CustomInstallPath`: <path> Set Custom install location.
- `/ForceRestart`: Always restart the system after installation.
- `/Full`: Install all product features.
- `/InstallSelectableItems`: <item1;item2;...;itemN> Choose which selectable item(s) to be installed.
selectable item to be installed, just pass in this switch without any value.
- `/Layout`: Create a copy of the media in specified folder.
- `/NoRefresh`: Prevent setup checking for updates from the internet.
- `/NoRestart`: Do not restart during or after installation.
- `/NoWeb`: Prevent setup downloading from the internet.
- `/Passive`: Display progress but do not wait for user input.
- `/ProductKey`: <25-character product key> Set custom product key (no dashes).
- `/PromptRestart`: Prompt the user before restarting the system.
- `/Repair`: Repair the product.
- `/Uninstall`: Uninstall the product.
- `/Uninstall /Force`: Uninstall the product and features shared with other products.
Supply parameters to `windows-build-tools` as a JSON array. Here's quick example (note the double quotes):
```
npm --vcc-build-tools-parameters='[""/InstallSelectableItems"", ""item1;item2;item3""]' install --global windows-build-tools
npm --vcc-build-tools-parameters='[""--allWorkloads""]' install --global windows-build-tools
```

@@ -91,2 +74,2 @@

Copyright (C) 2016 Felix Rieseberg and Microsoft Corporation. Licensed MIT. For more details, please see LICENSE.
Copyright (C) 2018 Felix Rieseberg. Licensed MIT. For more details, please see LICENSE.

@@ -5,11 +5,11 @@ 'use strict'

if (process.version === 'v7.1.0') {
const utils = require('./utils')
const { warn } = require('./logging')
utils.warn('--------------------------------------------------------------')
utils.warn('You are running Node v7.1.0, which has a known bug on Windows,')
utils.warn('breaking Node applications using the utils (Powershell/CMD).')
utils.warn('Please upgrade to a newer version or use Node v7.0.0.\n\n')
utils.warn('Visit https://github.com/nodejs/node/issues/9542 for details.\n')
utils.warn('windows-build-tools will now run, but might fail.')
utils.warn('---------------------------------------------------------------')
warn('--------------------------------------------------------------')
warn('You are running Node v7.1.0, which has a known bug on Windows,')
warn('breaking Node applications using the utils (Powershell/CMD).')
warn('Please upgrade to a newer version or use Node v7.0.0.\n\n')
warn('Visit https://github.com/nodejs/node/issues/9542 for details.\n')
warn('windows-build-tools will now run, but might fail.')
warn('---------------------------------------------------------------')
}

@@ -16,0 +16,0 @@

@@ -5,10 +5,9 @@ 'use strict'

let python = {}
const buildTools = {
installerName: 'BuildTools_Full.exe',
installerUrl: 'https://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe',
logName: 'build-tools-log.txt'
installerName: 'vs_BuildTools.exe',
installerUrl: 'https://download.visualstudio.microsoft.com/download/pr/11503713/e64d79b40219aea618ce2fe10ebd5f0d/vs_BuildTools.exe'
}
let python = {}
if (process.arch === 'x64') {

@@ -15,0 +14,0 @@ python = {

@@ -5,3 +5,5 @@ 'use strict'

const utils = require('./utils')
const { getBuildToolsInstallerPath } = require('./utils/get-build-tools-installer-path')
const { getPythonInstallerPath } = require('./utils/get-python-installer-path')
const { log } = require('./logging')

@@ -15,6 +17,6 @@ /**

function download (cb) {
downloadTools(utils.getBuildToolsInstallerPath())
.then(() => downloadTools(utils.getPythonInstallerPath()))
downloadTools(getBuildToolsInstallerPath())
.then(() => downloadTools(getPythonInstallerPath()))
.then(() => cb())
.catch((error) => utils.log(error))
.catch((error) => log(error))
}

@@ -53,3 +55,3 @@

utils.log(`Downloaded ${installer.fileName}. Saved to ${installer.path}.`)
log(`Downloaded ${installer.fileName}. Saved to ${installer.path}.`)
resolve(installer.path)

@@ -56,0 +58,0 @@ })

'use strict'
const path = require('path')
const utils = require('./utils')
const { executeChildProcess } = require('./utils/execute-child-process')

@@ -22,5 +22,5 @@ /**

return utils.executeChildProcess('powershell.exe', args)
return executeChildProcess('powershell.exe', args)
}
module.exports = setEnvironment
'use strict'
const path = require('path')
const spawn = require('child_process').spawn
const debug = require('debug')('windows-build-tools')

@@ -9,5 +7,7 @@ const chalk = require('chalk')

const { getPythonInstallerPath } = require('../utils/get-python-installer-path')
const { getWorkDirectory } = require('../utils/get-work-dir')
const { log } = require('../logging')
const launchInstaller = require('./launch')
const Tailer = require('./tailer')
const utils = require('../utils')

@@ -24,3 +24,3 @@ let spinner

function install (cb) {
utils.log(chalk.green('Starting installation...'))
log(chalk.green('Starting installation...'))

@@ -42,7 +42,7 @@ launchInstaller()

utils.log(error)
log(error)
})
}
function stopSpinner() {
function stopSpinner () {
if (spinner) {

@@ -53,5 +53,5 @@ spinner.stop(false)

function launchSpinner() {
utils.log('Launched installers, now waiting for them to finish.')
utils.log('This will likely take some time - please be patient!')
function launchSpinner () {
log('Launched installers, now waiting for them to finish.')
log('This will likely take some time - please be patient!')

@@ -65,13 +65,14 @@ spinner = new Spinner(`Waiting for installers... %s`)

return new Promise((resolve, reject) => {
const tailer = new Tailer(utils.getBuildToolsInstallerPath().logPath)
const tailer = new Tailer()
tailer.on('exit', (result, details) => {
debug('build tools tailer exited');
debug('Install: Build tools tailer exited')
if (result === 'error') {
debug('Installer: Tailer found error with installer', details)
reject(err)
reject()
}
if (result === 'success') {
utils.log(chalk.bold.green('Successfully installed Visual Studio Build Tools.'))
log(chalk.bold.green('Successfully installed Visual Studio Build Tools.'))
debug('Installer: Successfully installed Visual Studio Build Tools according to tailer')

@@ -82,5 +83,5 @@ resolve()

if (result === 'failure') {
utils.log(chalk.bold.red('Could not install Visual Studio Build Tools.'))
utils.log('Please find more details in the log files, which can be found at')
utils.log(utils.getWorkDirectory())
log(chalk.bold.red('Could not install Visual Studio Build Tools.'))
log('Please find more details in the log files, which can be found at')
log(getWorkDirectory())
debug('Installer: Failed to install according to tailer')

@@ -98,17 +99,17 @@ resolve()

// The log file for msiexe is utf-16
const tailer = new Tailer(utils.getPythonInstallerPath().logPath, 'ucs2')
const tailer = new Tailer(getPythonInstallerPath().logPath, 'ucs2')
tailer.on('exit', (result, details) => {
debug('python tailer exited');
debug('python tailer exited')
if (result === 'error') {
debug('Installer: Tailer found error with installer', details)
reject(err)
reject()
}
if (result === 'success') {
utils.log(chalk.bold.green('Successfully installed Python 2.7'))
log(chalk.bold.green('Successfully installed Python 2.7'))
debug('Installer: Successfully installed Python 2.7 according to tailer')
var variables = {
pythonPath: details || utils.getPythonInstallerPath().targetPath
pythonPath: details || getPythonInstallerPath().targetPath
}

@@ -119,5 +120,5 @@ resolve(variables)

if (result === 'failure') {
utils.log(chalk.bold.red('Could not install Python 2.7.'))
utils.log('Please find more details in the log files, which can be found at')
utils.log(utils.getWorkDirectory())
log(chalk.bold.red('Could not install Python 2.7.'))
log('Please find more details in the log files, which can be found at')
log(getWorkDirectory())
debug('Installer: Failed to install Python 2.7 according to tailer')

@@ -124,0 +125,0 @@ resolve(undefined)

@@ -8,6 +8,9 @@ 'use strict'

const utils = require('../utils')
const installer = utils.getBuildToolsInstallerPath()
const pythonInstaller = utils.getPythonInstallerPath()
const { log } = require('../logging')
const { getBuildToolsInstallerPath } = require('../utils/get-build-tools-installer-path')
const { getPythonInstallerPath } = require('../utils/get-python-installer-path')
const installer = getBuildToolsInstallerPath()
const pythonInstaller = getPythonInstallerPath()
/**

@@ -36,3 +39,2 @@ * Launches the installer, using a PS1 script as a middle-man

const scriptPath = path.join(__dirname, '..', '..', 'ps1', 'launch-installer.ps1')

@@ -49,4 +51,4 @@ const psArgs = `& {& '${scriptPath}' -path '${installer.directory}' -extraBuildToolsParameters '${extraArgs}' -pythonInstaller '${pythonInstaller.fileName}'}`

} catch (error) {
utils.log(chalk.bold.red('Error: failed while trying to run powershell.exe'))
utils.log('(Hint: Is "%SystemRoot%\\system32\\WindowsPowerShell\\v1.0" in your system path?)')
log(chalk.bold.red('Error: failed while trying to run powershell.exe'))
log('(Hint: Is "%SystemRoot%\\system32\\WindowsPowerShell\\v1.0" in your system path?)')
return reject(error)

@@ -59,5 +61,5 @@ }

if (data.toString().includes('Please restart this script from an administrative PowerShell!')) {
utils.log(chalk.bold.red('Please restart this script from an administrative PowerShell!'))
utils.log('The build tools cannot be installed without administrative rights.')
utils.log('To fix, right-click on PowerShell and run "as Administrator".')
log(chalk.bold.red('Please restart this script from an administrative PowerShell!'))
log('The build tools cannot be installed without administrative rights.')
log('To fix, right-click on PowerShell and run "as Administrator".')

@@ -74,2 +76,2 @@ // Bail out

module.exports = launchInstaller
module.exports = launchInstaller
'use strict'
const path = require('path')
const fs = require('fs-extra')

@@ -8,6 +7,6 @@ const debug = require('debug')('windows-build-tools')

const utils = require('../utils')
const { findVCCLogFile } = require('../utils/find-logfile')
class Tailer extends EventEmitter {
constructor(logfile, encoding = 'utf8') {
constructor (logfile, encoding = 'utf8') {
super()

@@ -21,4 +20,8 @@ this.logFile = logfile

*/
start() {
debug(`Tail: Waiting for log file to appear in ${this.logFile}`)
start () {
if (this.logFile) {
debug(`Tail: Waiting for log file to appear in ${this.logFile}`)
} else {
debug(`Tail: Waiting for log file to appear. Searching in %TEMP%`)
}
this.waitForLogFile()

@@ -30,3 +33,3 @@ }

*/
stop(...args) {
stop (...args) {
debug(`Tail: Stopping`, ...args)

@@ -40,3 +43,3 @@ this.emit('exit', ...args)

*/
tail() {
tail () {
debug(`Tail: Tailing ${this.logFile}`)

@@ -51,3 +54,3 @@ this.tail = setInterval(() => {

*/
handleData() {
handleData () {
let data

@@ -59,8 +62,9 @@

debug(`Tail start: Could not read logfile ${this.logFile}: ${err}`)
return
}
// Success strings for build tools
if (data.includes('Variable: IsInstalled = 1') ||
data.includes('Variable: BuildTools_Core_Installed = ') ||
data.includes('WixBundleInstalled = 1')) {
if (data.includes('Closing installer. Return code: 3010.') ||
data.includes('Closing installer. Return code: 0.')) {
debug(`Tail: Reporting success for VCC Build Tools`)
this.stop('success')

@@ -73,3 +77,3 @@ // Success strings for python

const matches = data.match(/Property\(S\): TARGETDIR = (.*)\r\n/)
let pythonPath = undefined
let pythonPath

@@ -79,4 +83,7 @@ if (matches) {

}
debug(`Tail: Reporting success for Python`)
this.stop('success', pythonPath)
} else if (data.includes('Shutting down, exit code:')) {
} else if (data.includes('Closing installer. Return code:') ||
data.includes('Shutting down, exit code:')) {
debug(`Tail: Reporting failure in ${this.logFile}`)
this.stop('failure')

@@ -95,15 +102,38 @@ }

*/
waitForLogFile() {
fs.lstat(this.logFile, (err, stats) => {
if (err && err.code === 'ENOENT') {
debug('Tail: waitForFile: still waiting')
setTimeout(this.waitForLogFile.bind(this), 2000)
} else if (err) {
debug('Tail: waitForFile: Unexpected error', err)
throw new Error(err);
} else {
debug(`Tail: waitForFile: Found ${this.logFile}`)
this.tail()
}
})
waitForLogFile () {
const handleStillWaiting = () => {
debug('Tail: waitForFile: still waiting')
setTimeout(this.waitForLogFile.bind(this), 2000)
}
const handleKnownPath = (logFile) => {
fs.lstat(logFile, (err, stats) => {
if (err && err.code === 'ENOENT') {
handleStillWaiting()
} else if (err) {
debug('Tail: waitForFile: Unexpected error', err)
throw new Error(err)
} else {
debug(`Tail: waitForFile: Found ${logFile}`)
this.tail()
}
})
}
// If don't have a logfile, we need to find one. The only one
// we need to find right now is the VCC 2017 logfile.
if (!this.logFile) {
findVCCLogFile().then((logFile) => {
debug(`Tail: LogFile found: ${logFile}`)
if (!logFile) {
handleStillWaiting()
} else {
this.logFile = logFile
handleKnownPath(logFile)
}
})
} else {
handleKnownPath(this.logFile)
}
}

@@ -110,0 +140,0 @@ }

@@ -7,2 +7,4 @@ 'use strict'

const installer = require('../../src/utils/get-build-tools-installer-path').getBuildToolsInstallerPath()
describe('DownloadTools', () => {

@@ -13,3 +15,2 @@ afterEach(() => mockery.deregisterAll())

it('should attempt to download the installer', (done) => {
const installer = require('../../src/utils').getBuildToolsInstallerPath()
const nuggetMock = function (url, options, cb) {

@@ -16,0 +17,0 @@ url.should.equal(installer.url)

@@ -15,3 +15,3 @@ 'use strict'

python: {
pythonPath: require('../../src/utils').getPythonInstallerPath().targetPath
pythonPath: require('../../src/utils/get-python-installer-path').getPythonInstallerPath().targetPath
}

@@ -18,0 +18,0 @@ }

@@ -14,5 +14,3 @@ 'use strict'

// Run tests
const download = require('./src/download');
const environment = require('./src/environment');
const installLaunch = require('./src/install/launch');
const installTailer = require('./src/install/tailer');
require('./src/download')
require('./src/environment')

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