aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgabrielluong2013-05-06 11:35:19 (EDT)
committerMark Macdonald2013-05-07 12:43:18 (EDT)
commit6f7caffca67c849600b1733cd2e4e021530db580 (patch)
tree411d548c68d3497c41dc059b7ef00b99f67b2153
parentfbdedf96d5843ac7788af52ce4d144500c8eb7c9 (diff)
downloadorg.eclipse.orion.client-6f7caffca67c849600b1733cd2e4e021530db580.zip
org.eclipse.orion.client-6f7caffca67c849600b1733cd2e4e021530db580.tar.gz
org.eclipse.orion.client-6f7caffca67c849600b1733cd2e4e021530db580.tar.bz2
Bug407209 - Added updateJS to replace define("{pageDir}/{name}" with define("built-{name}.js" in the build script
Signed-off-by: Mark Macdonald <Mark_MacDonald@ca.ibm.com>
-rw-r--r--modules/orionode/build/build.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/orionode/build/build.js b/modules/orionode/build/build.js
index a03f40b..3563bec 100644
--- a/modules/orionode/build/build.js
+++ b/modules/orionode/build/build.js
@@ -138,6 +138,7 @@ function build(optimizeElements) {
optimize: true,
css: true,
updateHtml: true,
+ updateJS: true,
copyBack: true
};
return dfs.exists(pathToTempDir).then(function(exists) {
@@ -253,6 +254,27 @@ function build(optimizeElements) {
};
}));
}).then(function() {
+ if (steps.updateJS === false) { return new Deferred().resolve(); }
+ section('Running updateJS');
+ return async.sequence(optimizes.map(function(op) {
+ return function() {
+ // Replace define("{pageDir}/{name}" with define("built-{name}.js" in built js files
+ // TODO check existence of path.join(pageDir, name) -- skip if the file doesn't exist
+ var pageDir = op.pageDir, name = op.name, builtJsFile = op.minifiedFilePath;
+ var buildResult = 'define("built-' + name + '.js"';
+ console.log("updateJS " + builtJsFile);
+ return dfs.readFile(builtJsFile, 'utf8').then(function(jsFile) {
+ jsFile = jsFile.replace("define('" + pageDir + "/" + name + "'", buildResult);
+ jsFile = jsFile.replace('define("' + pageDir + '/' + name + '"', buildResult);
+ return dfs.writeFile(builtJsFile, jsFile);
+ }, function(error) {
+ // log and continue
+ console.log(error.stack || error);
+ console.log('');
+ });
+ };
+ }));
+ }).then(function() {
if (steps.copyBack === false) { return new Deferred().resolve(); }
// Copy the built files from our .temp directory back to their original locations in the bundles folder
// TODO: should create a separate 'optimized' source folder to avoid polluting the lib/orion.client/ folder.