forked from blackberry/BB10-WebWorks-Framework
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bundle process to create single webworks.js. Used require aspec…
…t as per discussion. Added new jake task to bundle together webworks.js: jake bundle
- Loading branch information
Rowell Cruz
committed
Dec 7, 2011
1 parent
54aa0ca
commit 0182d03
Showing
6 changed files
with
738 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var fs = require('fs'); | ||
|
||
module.exports = { | ||
bundle: function () { | ||
var fs = require('fs'), | ||
files = [ | ||
"lib/public/builder.js" | ||
], | ||
include = function (files, transform) { | ||
files = files.map ? files : [files]; | ||
return files.map(function (file) { | ||
var str = fs.readFileSync(file, "utf-8") + "\n"; | ||
return transform ? transform(str, file) : str; | ||
}).join('\n'); | ||
}, | ||
output = "", | ||
filepath; | ||
|
||
//include LICENSE | ||
output += include("LICENSE", function (file) { | ||
return "/*\n" + file + "\n*/\n"; | ||
}); | ||
|
||
//include require | ||
output += include("dependencies/browser-require/require.js"); | ||
|
||
//include modules | ||
output += include(files, function (file, path) { | ||
return "require.define('" + path.replace(/lib\/public/, "").replace(/\.js$/, "") + | ||
"', function (require, module, exports) {\n" + file + "});\n"; | ||
}); | ||
|
||
//include window.webworks | ||
output += include("lib/public/window-webworks.js"); | ||
|
||
filepath = __dirname.replace(/\\/g, '/'); | ||
fs.writeFileSync(filepath + "/../../lib/public/webworks.js", output); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.