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
This commit is contained in:
Doug Bunting 2015-02-05 12:16:53 -08:00
parent f1154a850c
commit 530d655d59
3 changed files with 15 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}
}