From 6d39addb5beb31965ec1a0693b01efdb175d3bca Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sat, 31 Jan 2015 17:29:25 -0800 Subject: [PATCH] Create target directory for `npm` installations - #144 - problems seem primarily to occur when `node` is globally installed but a package (`grunt` or `bower`) is not; `npm install X` fails in this case - create the `--prefix` directory first to avoid these installation failures - change _node-install.shade to avoid confusion when directory exists --- build/_node-install.shade | 4 ++-- build/_npm.shade | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build/_node-install.shade b/build/_node-install.shade index eb8d8051fd..28394addc6 100644 --- a/build/_node-install.shade +++ b/build/_node-install.shade @@ -10,17 +10,17 @@ default nodeVer = '0.10.28' default npmVer = '1.4.9' default nodeExeSha = '628FFD6C3577068C00CEC9F6F897F0EC8F5212D9' default nodeInstallDir = '${Path.Combine(binDir, "nodejs")}' -default nodeGloballyInstalled = '${ !Directory.Exists(nodeInstallDir) && TestCommand("node" , "--version") }' var nodeExe = 'node.exe' var npmZip = 'npm-${npmVer}.zip' var nodeDist = 'http://nodejs.org/dist/' var nodeUrl = '${nodeDist}v${nodeVer}/${nodeExe}' var npmUrl = '${nodeDist}npm/${npmZip}' -var doInstall = '${!nodeGloballyInstalled && !Directory.Exists(nodeInstallDir)}' var nodeInstallExePath = '${Path.Combine(nodeInstallDir, nodeExe)}' var npmInstallZipPath = '${Path.Combine(nodeInstallDir, npmZip)}' +var doInstall = '${ !File.Exists(nodeInstallExePath) && !TestCommand("node", "--version") }' + @{ if (doInstall) { Log.Info("Installing nodejs locally"); diff --git a/build/_npm.shade b/build/_npm.shade index 8f885cc5cf..88be524e29 100644 --- a/build/_npm.shade +++ b/build/_npm.shade @@ -7,5 +7,10 @@ node-install once='installNode' var npmFile = '${ Path.Combine(nodeDir, "npm.cmd") }' var npmCmd = '${ File.Exists(npmFile) ? npmFile : "npm" }' +- // Ensure nodeDir exists. npmCommand is likely a package installation targeting that directory. +@{ + Directory.CreateDirectory(nodeDir); +} + exec program='cmd' commandline='/C ${npmCmd} ${npmCommand}' workingdir='${npmDir}' if='!IsLinux' exec program='${npmCmd}' commandline='${npmCommand}' workingdir='${npmDir}' if='IsLinux' \ No newline at end of file