From 30e875eeba9ca63d40ada201c6d21e1d0c3dc7cb Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Tue, 7 Feb 2017 11:40:53 -0500 Subject: [PATCH] style --- lib/gyp/generator/ninja/index.js | 8 +++++--- lib/gyp/platform/win.js | 18 +++++++++++------- test/platform-win-test.js | 8 +++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/gyp/generator/ninja/index.js b/lib/gyp/generator/ninja/index.js index 201d62c..93f8de5 100644 --- a/lib/gyp/generator/ninja/index.js +++ b/lib/gyp/generator/ninja/index.js @@ -353,8 +353,8 @@ Ninja.prototype.actionCmd = function actionCmd(base, toBase, cmds) { if (this.flavor !== 'win32') return res; - // TODO(indutny): escape quotes in res - return `${gyp.platform.win.ninjaWrap} powershell -Command ${res.replace(/ & /g, ' ; ')}`; + const wrap = gyp.platform.win.ninjaWrap; + return `${wrap} powershell -Command ${res.replace(/ & /g, ' ; ')}`; }; Ninja.prototype.copies = function copies() { @@ -420,7 +420,9 @@ Ninja.prototype.actions = function actions() { res = res.concat(outputs); if (action.process_outputs_as_sources === '1') { - this.targetDict.sources = (this.targetDict.sources || []).concat(action.outputs); + let trg = this.targetDict; + trg.sources = trg.sources || []; + trg.sources = trg.sources.concat(action.outputs); } this.n.build(actionRule, outputs, inputs, { diff --git a/lib/gyp/platform/win.js b/lib/gyp/platform/win.js index e3a02cd..d56cfed 100644 --- a/lib/gyp/platform/win.js +++ b/lib/gyp/platform/win.js @@ -396,7 +396,8 @@ win.getOSBits = function getOSBits() { function tryVS7(hostBits, target_arch) { try { - const psFile = path.join(__dirname, '..', '..', '..', 'tools', 'Get-VSConfig.ps1'); + const psFile = path.join(__dirname, + '..', '..', '..', 'tools', 'Get-VSConfig.ps1'); const vsSetupRaw = gyp.bindings.execSync(`powershell ${psFile}`).toString(); if (!vsSetupRaw) return; const vsSetup = vsSetupRaw.split(/[\r|\n]/g).reduce((s, l) => { @@ -404,7 +405,8 @@ function tryVS7(hostBits, target_arch) { if (lParts.length > 1) s[lParts[0]] = lParts[1]; return s; }, {}); - const VsDevCmd = path.join(vsSetup.InstallationPath, 'Common7', 'Tools', 'VsDevCmd.bat'); + const VsDevCmd = path.join(vsSetup.InstallationPath, + 'Common7', 'Tools', 'VsDevCmd.bat'); const argArch = target_arch === 'x64' ? 'amd64' : 'x86'; const argHost = hostBits === 64 ? 'amd64' : 'x86'; return `${VsDevCmd} -arch=${argArch} -host_arch=${argHost} -no_logo`; @@ -446,7 +448,9 @@ function findOldVcVarsFile(hostBits, target_arch) { if (hostBits === 64) vcEnvCmd = '"' + path.join(tools, 'VC', 'vcvarsall.bat') + '" amd64_x86'; else - vcEnvCmd = '"' + path.join(tools, 'Common7', 'Tools', 'vsvars32.bat') + '"'; + vcEnvCmd = '"' + + path.join(tools, 'Common7', 'Tools', 'vsvars32.bat') + + '"'; } else if (target_arch === 'x64') { let arg; if (hostBits === 64) @@ -463,8 +467,8 @@ function findOldVcVarsFile(hostBits, target_arch) { win.resolveDevEnvironment = function resolveDevEnvironment(target_arch) { const hostBits = win.getOSBits(); - const vcEnvCmd = tryVS7(hostBits, target_arch) - || findOldVcVarsFile(hostBits, target_arch); + const vcEnvCmd = tryVS7(hostBits, target_arch) || + findOldVcVarsFile(hostBits, target_arch); let lines = []; try { lines = gyp.bindings.execSync(`${vcEnvCmd} & set`, {env: {}}).toString() @@ -481,8 +485,8 @@ win.resolveDevEnvironment = function resolveDevEnvironment(target_arch) { return env; }; -const IMPORTANT_VARS = - /^include|lib|libpath|path|pathext|systemroot|temp|tmp$/i; +// const IMPORTANT_VARS = +// /^include|lib|libpath|path|pathext|systemroot|temp|tmp$/i; win.genEnvironment = function genEnvironment(outDir, target_arch) { const env = win.resolveDevEnvironment(target_arch); diff --git a/test/platform-win-test.js b/test/platform-win-test.js index 628075b..bdbfc88 100644 --- a/test/platform-win-test.js +++ b/test/platform-win-test.js @@ -233,10 +233,11 @@ describe('gyp.platform.win', () => { assert(env, 'didn\'t get ENVIRONMENT :('); const COMNTOOLS = Object.keys(env).find(k => k.includes('COMNTOOLS')); assert(COMNTOOLS, 'didn\'t get COMNTOOLS :('); - if (COMNTOOLS === 'VS150COMNTOOLS'){ + if (COMNTOOLS === 'VS150COMNTOOLS') { assert.equal(env['VSCMD_ARG_TGT_ARCH'], 'x64'); assert.equal(env['VisualStudioVersion'], '15.0'); - assert(env['__VSCMD_PREINIT_PATH'], 'Last env var should be __VSCMD_PREINIT_PATH'); + assert(env['__VSCMD_PREINIT_PATH'], + 'Last env var should be __VSCMD_PREINIT_PATH'); } }); @@ -248,7 +249,8 @@ describe('gyp.platform.win', () => { if (COMNTOOLS === 'VS150COMNTOOLS') { assert.equal(env['VSCMD_ARG_TGT_ARCH'], 'x86'); assert.equal(env['VisualStudioVersion'], '15.0'); - assert(env['__VSCMD_PREINIT_PATH'], 'Last env var should be __VSCMD_PREINIT_PATH'); + assert(env['__VSCMD_PREINIT_PATH'], + 'Last env var should be __VSCMD_PREINIT_PATH'); } }); });