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:
parent
f1154a850c
commit
530d655d59
|
|
@ -1,9 +1,9 @@
|
||||||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||||
|
|
||||||
var bowerLibrary = '${ Path.Combine(nodeDir, "node_modules", "bower", "bin", "bower") }'
|
var bowerLibrary = '${ Path.Combine(nodeDir, "node_modules", "bower", "bin", "bower") }'
|
||||||
var bowerInstalled = '${ File.Exists(bowerLibrary) }'
|
var bowerInstalled = '${ File.Exists(bowerLibrary) }'
|
||||||
var bowerGloballyInstalled = '${ !bowerInstalled && TestCommand("bower", "--version") }'
|
|
||||||
|
default bowerGloballyInstalled = '${ !bowerInstalled && TestCommand("bower", "--version") }'
|
||||||
var bowerCmd = '${ bowerGloballyInstalled ? "bower" : bowerLibrary }'
|
var bowerCmd = '${ bowerGloballyInstalled ? "bower" : bowerLibrary }'
|
||||||
|
|
||||||
- // Install bower locally if not already installed either globally or locally; creates bowerLibrary file if run
|
- // Install bower locally if not already installed either globally or locally; creates bowerLibrary file if run
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||||
|
|
||||||
var gruntCliLibrary = '${ Path.Combine(nodeDir, "node_modules", "grunt-cli", "bin", "grunt") }'
|
var gruntCliLibrary = '${ Path.Combine(nodeDir, "node_modules", "grunt-cli", "bin", "grunt") }'
|
||||||
var gruntCliInstalled = '${ File.Exists(gruntCliLibrary) }'
|
var gruntCliInstalled = '${ File.Exists(gruntCliLibrary) }'
|
||||||
var gruntCliGloballyInstalled = '${ !gruntCliInstalled && TestCommand("grunt", "--version") }'
|
|
||||||
|
default gruntCliGloballyInstalled = '${ !gruntCliInstalled && TestCommand("grunt", "--version") }'
|
||||||
var gruntCmd = '${ gruntCliGloballyInstalled ? "grunt" : gruntCliLibrary }'
|
var gruntCmd = '${ gruntCliGloballyInstalled ? "grunt" : gruntCliLibrary }'
|
||||||
|
|
||||||
- // Install grunt-cli locally if not already installed either globally or locally; creates gruntCliLibrary file if run
|
- // Install grunt-cli locally if not already installed either globally or locally; creates gruntCliLibrary file if run
|
||||||
|
|
|
||||||
|
|
@ -9,27 +9,29 @@ default binDir = '${Path.Combine(Directory.GetCurrentDirectory(), "bin")}'
|
||||||
default nodeVer = '0.10.28'
|
default nodeVer = '0.10.28'
|
||||||
default npmVer = '1.4.9'
|
default npmVer = '1.4.9'
|
||||||
default nodeExeSha = '628FFD6C3577068C00CEC9F6F897F0EC8F5212D9'
|
default nodeExeSha = '628FFD6C3577068C00CEC9F6F897F0EC8F5212D9'
|
||||||
default nodeInstallDir = '${Path.Combine(binDir, "nodejs")}'
|
default nodeDir = '${Path.Combine(binDir, "nodejs")}'
|
||||||
|
|
||||||
var nodeExe = 'node.exe'
|
var nodeExe = 'node.exe'
|
||||||
var npmZip = 'npm-${npmVer}.zip'
|
var npmZip = 'npm-${npmVer}.zip'
|
||||||
var nodeDist = 'http://nodejs.org/dist/'
|
var nodeDist = 'http://nodejs.org/dist/'
|
||||||
var nodeUrl = '${nodeDist}v${nodeVer}/${nodeExe}'
|
var nodeUrl = '${nodeDist}v${nodeVer}/${nodeExe}'
|
||||||
var npmUrl = '${nodeDist}npm/${npmZip}'
|
var npmUrl = '${nodeDist}npm/${npmZip}'
|
||||||
var nodeInstallExePath = '${Path.Combine(nodeInstallDir, nodeExe)}'
|
var nodeInstallExePath = '${Path.Combine(nodeDir, nodeExe)}'
|
||||||
var npmInstallZipPath = '${Path.Combine(nodeInstallDir, npmZip)}'
|
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) {
|
if (doInstall) {
|
||||||
Log.Info("Installing nodejs locally");
|
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
|
// Download node
|
||||||
var wc = new WebClient();
|
var wc = new WebClient();
|
||||||
|
|
@ -41,8 +43,8 @@ var doInstall = '${ !File.Exists(nodeInstallExePath) && !TestCommand("node", "--
|
||||||
wc.DownloadFile(npmUrl, npmInstallZipPath);
|
wc.DownloadFile(npmUrl, npmInstallZipPath);
|
||||||
|
|
||||||
// Unzip npm
|
// Unzip npm
|
||||||
Log.Info(string.Format("Unzipping npm to {0}", nodeInstallDir));
|
Log.Info(string.Format("Unzipping npm to {0}", nodeDir));
|
||||||
ZipFile.ExtractToDirectory(npmInstallZipPath, nodeInstallDir);
|
ZipFile.ExtractToDirectory(npmInstallZipPath, nodeDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue