53 lines
1.9 KiB
Plaintext
53 lines
1.9 KiB
Plaintext
use assembly="System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
use namespace="System.IO"
|
|
use namespace="System.IO.Compression"
|
|
use namespace="System.Net"
|
|
|
|
default binDir = '${Path.Combine(Directory.GetCurrentDirectory(), "bin")}'
|
|
|
|
-// When updating the node version you need to update the nodeExeSha to match what 'signtool.exe /pa /v node.exe' emits
|
|
default nodeVer = '0.10.28'
|
|
default npmVer = '1.4.9'
|
|
default nodeExeSha = '628FFD6C3577068C00CEC9F6F897F0EC8F5212D9'
|
|
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(nodeDir, nodeExe)}'
|
|
var npmInstallZipPath = '${Path.Combine(nodeDir, npmZip)}'
|
|
var nodeInstalled = '${ File.Exists(nodeInstallExePath) }'
|
|
|
|
default nodeGloballyInstalled = '${ !nodeInstalled && TestCommand("node", "--version") }'
|
|
|
|
-// Command simply fails on Linux if nodejs is not available.
|
|
var doInstall = '${ !IsLinux && !(nodeGloballyInstalled || nodeInstalled) }'
|
|
|
|
@{
|
|
if (doInstall) {
|
|
Log.Info("Installing nodejs locally");
|
|
|
|
if (Directory.Exists(nodeDir))
|
|
{
|
|
Directory.Delete(nodeDir, recursive: true);
|
|
}
|
|
Directory.CreateDirectory(nodeDir);
|
|
|
|
// Download node
|
|
var wc = new WebClient();
|
|
|
|
Log.Info(string.Format("Downloading {0} to {1}", nodeUrl, nodeInstallExePath));
|
|
wc.DownloadFile(nodeUrl, nodeInstallExePath);
|
|
|
|
Log.Info(string.Format("Downloading {0} to {1}", npmUrl, npmInstallZipPath));
|
|
wc.DownloadFile(npmUrl, npmInstallZipPath);
|
|
|
|
// Unzip npm
|
|
Log.Info(string.Format("Unzipping npm to {0}", nodeDir));
|
|
ZipFile.ExtractToDirectory(npmInstallZipPath, nodeDir);
|
|
}
|
|
}
|
|
|
|
verify-authenticode verifyFilePath='${nodeInstallExePath}' expectedHash='${nodeExeSha}' if='doInstall' |