Fixed node/npm/grunt tasks to use global install if available
This commit is contained in:
parent
861e3df43b
commit
79111650f0
|
|
@ -1,7 +1,7 @@
|
||||||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||||
|
|
||||||
var bowerGloballyInstalled = '${TestCommand("bower --version")}'
|
var bowerGloballyInstalled = '${TestCommand("bower", "--version")}'
|
||||||
var bowerInstalled = '${Directory.Exists(Path.Combine(nodeDir, "node_modules", "bower"))}'
|
var bowerInstalled = '${Directory.Exists(Path.Combine(nodeDir, "node_modules", "bower"))}'
|
||||||
var bowerCmd = '${ bowerGloballyInstalled ? "bower" : Path.Combine(nodeDir, "node_modules", "bower", "bin", "bower") }'
|
var bowerCmd = '${ bowerGloballyInstalled ? "bower" : Path.Combine(nodeDir, "node_modules", "bower", "bin", "bower") }'
|
||||||
|
|
||||||
|
|
@ -9,5 +9,5 @@ var bowerCmd = '${ bowerGloballyInstalled ? "bower" : Path.Combine(nodeDir, "nod
|
||||||
npm npmCommand='install --prefix ${nodeDir} bower' if='!(bowerGloballyInstalled || bowerInstalled)' once='installBower'
|
npm npmCommand='install --prefix ${nodeDir} bower' if='!(bowerGloballyInstalled || bowerInstalled)' once='installBower'
|
||||||
|
|
||||||
- // Run bower
|
- // Run bower
|
||||||
exec program='${bowerCmd}' commandline='${bowerCommand}' if='bowerGloballyInstalled'
|
exec program='cmd' commandline='/C ${bowerCmd} ${bowerCommand}' workingdir='${bowerDir}' if='bowerGloballyInstalled'
|
||||||
node nodeCommand='${bowerCmd} ${bowerCommand}' workingdir='${bowerDir}' if='!bowerGloballyInstalled'
|
node nodeCommand='${bowerCmd} ${bowerCommand}' workingdir='${bowerDir}' if='!bowerGloballyInstalled'
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||||
|
|
||||||
|
var gruntCliGloballyInstalled = '${TestCommand("grunt", "--version")}'
|
||||||
var gruntCliInstalled = '${Directory.Exists(Path.Combine(nodeDir, "node_modules", "grunt-cli"))}'
|
var gruntCliInstalled = '${Directory.Exists(Path.Combine(nodeDir, "node_modules", "grunt-cli"))}'
|
||||||
|
var gruntCmd = '${ gruntCliGloballyInstalled ? "grunt" : Path.Combine(nodeDir, "node_modules", "grunt-cli") }'
|
||||||
|
|
||||||
-// Install grunt-cli locally
|
-// Install grunt-cli locally
|
||||||
npm npmCommand='install --prefix ${nodeDir} grunt-cli' if='!gruntCliInstalled' once='installGruntCli'
|
npm npmCommand='install --prefix ${nodeDir} grunt-cli' if='!(gruntCliGloballyInstalled || gruntCliInstalled)' once='installGruntCli'
|
||||||
|
|
||||||
-// Run grunt
|
-// Run grunt
|
||||||
node nodeCommand='${Path.Combine(nodeDir, "node_modules", "grunt-cli", "bin", "grunt")}' workingdir='${gruntDir}'
|
exec program='cmd' commandline='/C ${gruntCmd}' workingdir='${gruntDir}' if='gruntCliGloballyInstalled'
|
||||||
|
node nodeCommand='${Path.Combine(nodeDir, "node_modules", "grunt-cli", "bin", "grunt")}' workingdir='${gruntDir}' if='!gruntCliGloballyInstalled'
|
||||||
|
|
@ -115,29 +115,29 @@ functions @{
|
||||||
.Select(p => Path.GetDirectoryName(p))
|
.Select(p => Path.GetDirectoryName(p))
|
||||||
.Distinct();
|
.Distinct();
|
||||||
}
|
}
|
||||||
bool TestCommand(string program, string commandline = null) {
|
bool TestCommand(string program, string commandline) {
|
||||||
// Tests whether a given command succeeds at the command line.
|
// Tests whether a given command succeeds at the command line.
|
||||||
// Useful for testing whether a given command is installed and on the path, e.g. node
|
// Useful for testing whether a given command is installed and on the path, e.g. node
|
||||||
var processStartInfo = new ProcessStartInfo {
|
var processStartInfo = new ProcessStartInfo {
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
WorkingDirectory = Directory.GetCurrentDirectory(),
|
FileName = "cmd",
|
||||||
FileName = program,
|
Arguments = "/C " + program + " " + commandline,
|
||||||
Arguments = commandline,
|
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
Log.Info(string.Format("Testing for command: {0} {1}", program, commandline));
|
Log.Info(string.Format("Testing for command: {0} {1}", program, commandline));
|
||||||
var process = Process.Start(processStartInfo);
|
var process = Process.Start(processStartInfo);
|
||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
if (process.ExitCode == 0) {
|
if (process.ExitCode == 0) {
|
||||||
Log.Info(" command found");
|
Log.Info(" command found (0 exit code)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.Warn(" command not found");
|
Log.Warn(" command not found (non-0 exit code)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) {
|
catch (Exception ex) {
|
||||||
|
Log.Warn(" command exception: " + ex.ToString());
|
||||||
Log.Warn(" command not found");
|
Log.Warn(" command not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ 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 nodeInstallDir = '${Path.Combine(binDir, "nodejs")}'
|
||||||
default nodeGloballyInstalled = '${TestCommand("node --version")}'
|
default nodeGloballyInstalled = '${TestCommand("node" , "--version")}'
|
||||||
|
|
||||||
var nodeExe = 'node.exe'
|
var nodeExe = 'node.exe'
|
||||||
var npmZip = 'npm-${npmVer}.zip'
|
var npmZip = 'npm-${npmVer}.zip'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
default currentDir = '${Directory.GetCurrentDirectory()}'
|
default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||||
default nodeDir = '${Path.Combine(currentDir, "bin", "node")}'
|
default nodeDir = '${Path.Combine(currentDir, "bin", "node")}'
|
||||||
default nodeGloballyInstalled = '${TestCommand("node --version")}'
|
default nodeGloballyInstalled = '${TestCommand("node", "--version")}'
|
||||||
|
|
||||||
var nodeExePath = '${ nodeGloballyInstalled ? "node" : Path.Combine(nodeDir, "node.exe") }'
|
var nodeExePath = '${ nodeGloballyInstalled ? "node" : Path.Combine(nodeDir, "node.exe") }'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ default currentDir = '${Directory.GetCurrentDirectory()}'
|
||||||
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
default nodeDir = '${Path.Combine(currentDir, "bin", "nodejs")}'
|
||||||
default npmDir = '${currentDir}'
|
default npmDir = '${currentDir}'
|
||||||
|
|
||||||
var npmGloballyInstalled = '${TestCommand("npm --version")}'
|
var npmGloballyInstalled = '${TestCommand("npm" , "--version")}'
|
||||||
var npmCmd = '${ npmGloballyInstalled ? "npm" : Path.Combine(nodeDir, "npm.cmd") }'
|
var npmCmd = '${ npmGloballyInstalled ? "npm" : Path.Combine(nodeDir, "npm.cmd") }'
|
||||||
|
|
||||||
node-install once='installNode'
|
node-install once='installNode'
|
||||||
exec program='${npmCmd}' commandline='${npmCommand}' workingdir='${npmDir}'
|
exec program='cmd' commandline='/C ${npmCmd} ${npmCommand}' workingdir='${npmDir}'
|
||||||
Loading…
Reference in New Issue