From 530d655d5946056ecb314f1d4cd94679ce1a6ce3 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 5 Feb 2015 12:16:53 -0800 Subject: [PATCH] Use `default` for `*GloballyInstalled` variables - allows calling .shade files to avoid repeated `TestCommand()` calls nit in _node-install.shade: - name `default nodeDir` variable to match other shade files; reusing value --- build/_bower.shade | 4 ++-- build/_grunt.shade | 4 ++-- build/_node-install.shade | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/build/_bower.shade b/build/_bower.shade index 2218684739..10485f06a5 100644 --- a/build/_bower.shade +++ b/build/_bower.shade @@ -1,9 +1,9 @@ default currentDir = '${Directory.GetCurrentDirectory()}' default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}' - var bowerLibrary = '${ Path.Combine(nodeDir, "node_modules", "bower", "bin", "bower") }' var bowerInstalled = '${ File.Exists(bowerLibrary) }' -var bowerGloballyInstalled = '${ !bowerInstalled && TestCommand("bower", "--version") }' + +default bowerGloballyInstalled = '${ !bowerInstalled && TestCommand("bower", "--version") }' var bowerCmd = '${ bowerGloballyInstalled ? "bower" : bowerLibrary }' - // Install bower locally if not already installed either globally or locally; creates bowerLibrary file if run diff --git a/build/_grunt.shade b/build/_grunt.shade index c1332152cf..d98e4d62a0 100644 --- a/build/_grunt.shade +++ b/build/_grunt.shade @@ -1,9 +1,9 @@ default currentDir = '${Directory.GetCurrentDirectory()}' default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}' - var gruntCliLibrary = '${ Path.Combine(nodeDir, "node_modules", "grunt-cli", "bin", "grunt") }' var gruntCliInstalled = '${ File.Exists(gruntCliLibrary) }' -var gruntCliGloballyInstalled = '${ !gruntCliInstalled && TestCommand("grunt", "--version") }' + +default gruntCliGloballyInstalled = '${ !gruntCliInstalled && TestCommand("grunt", "--version") }' var gruntCmd = '${ gruntCliGloballyInstalled ? "grunt" : gruntCliLibrary }' - // Install grunt-cli locally if not already installed either globally or locally; creates gruntCliLibrary file if run diff --git a/build/_node-install.shade b/build/_node-install.shade index 28394addc6..656d0dd0e4 100644 --- a/build/_node-install.shade +++ b/build/_node-install.shade @@ -9,27 +9,29 @@ default binDir = '${Path.Combine(Directory.GetCurrentDirectory(), "bin")}' default nodeVer = '0.10.28' default npmVer = '1.4.9' default nodeExeSha = '628FFD6C3577068C00CEC9F6F897F0EC8F5212D9' -default nodeInstallDir = '${Path.Combine(binDir, "nodejs")}' +default nodeDir = '${Path.Combine(binDir, "nodejs")}' 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 nodeInstallExePath = '${Path.Combine(nodeInstallDir, nodeExe)}' -var npmInstallZipPath = '${Path.Combine(nodeInstallDir, npmZip)}' +var nodeInstallExePath = '${Path.Combine(nodeDir, nodeExe)}' +var npmInstallZipPath = '${Path.Combine(nodeDir, npmZip)}' +var nodeInstalled = '${ File.Exists(nodeInstallExePath) }' -var doInstall = '${ !File.Exists(nodeInstallExePath) && !TestCommand("node", "--version") }' +default nodeGloballyInstalled = '${ !nodeInstalled && TestCommand("node", "--version") }' +var doInstall = '${ !(nodeGloballyInstalled || nodeInstalled) }' @{ if (doInstall) { Log.Info("Installing nodejs locally"); - if (Directory.Exists(nodeInstallDir)) + if (Directory.Exists(nodeDir)) { - Directory.Delete(nodeInstallDir, recursive: true); + Directory.Delete(nodeDir, recursive: true); } - Directory.CreateDirectory(nodeInstallDir); + Directory.CreateDirectory(nodeDir); // Download node var wc = new WebClient(); @@ -41,8 +43,8 @@ var doInstall = '${ !File.Exists(nodeInstallExePath) && !TestCommand("node", "-- wc.DownloadFile(npmUrl, npmInstallZipPath); // Unzip npm - Log.Info(string.Format("Unzipping npm to {0}", nodeInstallDir)); - ZipFile.ExtractToDirectory(npmInstallZipPath, nodeInstallDir); + Log.Info(string.Format("Unzipping npm to {0}", nodeDir)); + ZipFile.ExtractToDirectory(npmInstallZipPath, nodeDir); } }