Permalink
Browse files

ENYO-1189: do not deploy.js in verbose mode, unless otherwise specified

Enyo-DCO-1.1-Signed-off-by: Francois-Xavier KOWALSKI <francois-xavier.kowalski@hp.com>
  • Loading branch information...
1 parent 3f70967 commit e59022919c4c94cca3b5024f9f8ecc2c4120d691 @asnowfix asnowfix committed Nov 13, 2012
Showing with 27 additions and 15 deletions.
  1. +27 −15 tools/deploy.js
View
@@ -50,7 +50,7 @@ process.on('uncaughtException', function (err) {
console.error(err.stack);
if (process.send) {
// only available if parent process is node
- process.send({error: err});
+ process.send({error: err.toString()});
}
process.exit(1);
});
@@ -75,14 +75,16 @@ var node = process.argv[0],
buildDir = path.resolve(sourceDir, "build"),
name = path.basename(sourceDir),
outDir = path.resolve(sourceDir, 'deploy', name),
- less = true; // LESS compilation, turned on by default
+ less = true, // LESS compilation, turned on by default
+ verbose = false;
function printUsage() {
// format generated using node-optimist...
console.log('\n'
+ 'Usage: ' + node + ' ' + deploy + ' [-c][-e enyo_dir][-b build_dir][-o out_dir][-p package_js][-s source_dir]\n'
+ '\n'
+ 'Options:\n'
+ + ' -v verbose operation [boolean] [default: ' + verbose + ']\n'
+ ' -b alternate build directory [default: "' + buildDir + '"]\n'
+ ' -c do not run the LESS compiler [boolean] [default: ' + less + ']\n'
+ ' -e location of the enyo framework [default: "' + enyoDir + '"]\n'
@@ -99,6 +101,7 @@ var opt = nopt(/*knownOpts*/ {
"out": path,
"packagejs": path,
"source": path,
+ "verbose": Boolean,
"help": Boolean
}, /*shortHands*/ {
"b": "--build",
@@ -107,6 +110,7 @@ var opt = nopt(/*knownOpts*/ {
"o": "--out",
"p": "--packagejs",
"s": "--source",
+ "v": "--verbose",
"h": "--help",
"?": "--help"
}, process.argv /*args*/, 2 /*slice*/);
@@ -127,22 +131,25 @@ sourceDir = opt.source
|| (opt.packagejs ? path.dirname(opt.packagejs) : undefined)
|| sourceDir;
less = !(opt.less === false) && less;
+verbose = opt.verbose;
var minifier = path.resolve(enyoDir, 'tools', 'minifier', 'minify.js');
-console.log("Using: build_dir=" + buildDir);
-console.log("Using: enyo_dir=" + enyoDir);
-console.log("Using: out_dir=" + outDir);
-console.log("Using: packagejs=" + packageJs);
-console.log("Using: source_dir=" + sourceDir);
-console.log("Using: less=" + less);
+if (verbose) console.log("Using: build_dir=" + buildDir);
+if (verbose) console.log("Using: enyo_dir=" + enyoDir);
+if (verbose) console.log("Using: out_dir=" + outDir);
+if (verbose) console.log("Using: packagejs=" + packageJs);
+if (verbose) console.log("Using: source_dir=" + sourceDir);
+if (verbose) console.log("Using: less=" + less);
// utils
function run(args) {
var command = args.join(' ');
- console.log("Running: '", command, "' from '", process.cwd(), "'");
- if (shell.exec(command).code !== 0) {
- throw new Error("*** Fail: '" + command + "'");
+ var report;
+ if (verbose) console.log("Running: '", command, "' from '", process.cwd(), "'");
+ report = shell.exec(command, { silent: true });
+ if (report.code !== 0) {
+ throw new Error("Fail: '" + command + "'\n" + report.output);
}
}
@@ -154,7 +161,7 @@ shell.mkdir('-p', path.join(outDir));
// Build / Minify
-console.log("Minify-ing the embedded Enyo...");
+console.log("Minify-ing Enyo...");
process.chdir(path.resolve(enyoDir, 'minify'));
run([node, minifier,
'-no-alias',
@@ -164,7 +171,7 @@ run([node, minifier,
'-output', path.join(buildDir, 'enyo'),
'package.js']);
-console.log("Minify-ing the application");
+console.log("Minify-ing the application...");
process.chdir(sourceDir);
process.chdir(path.dirname(packageJs));
run([node, minifier,
@@ -178,7 +185,12 @@ process.chdir(sourceDir);
shell.mkdir('-p', path.join(outDir, 'lib'));
shell.cp(path.join(sourceDir, 'index.html'), path.join(sourceDir, 'icon.png'), outDir);
-shell.cp('-r', path.join(sourceDir, 'assets'), buildDir, outDir);
+shell.cp('-r', buildDir, outDir);
+
+var assetsSrcDir = path.join(sourceDir, 'assets');
+if(shell.test('-d', assetsSrcDir)) {
+ shell.cp('-r', assetsSrcDir, outDir);
+}
var libSrcDir = path.join(sourceDir, 'lib');
if(shell.test('-d', libSrcDir)) {
@@ -210,7 +222,7 @@ function deployLib(lib) {
}
}
-console.log("Success");
+console.log("Success: the deployable application is available in: ", outDir);
process.exit(0);

0 comments on commit e590229

Please sign in to comment.