Skip to content

Commit

Permalink
quick build script to bundle everything together for the web
Browse files Browse the repository at this point in the history
  • Loading branch information
gtanner committed Nov 15, 2011
1 parent c1587da commit fafcf2f
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg/
tags
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "thirdparty/browser-require"]
path = thirdparty/browser-require
url = https://github.com/rsms/browser-require.git
[submodule "node_modules/uglify-js"]
path = node_modules/uglify-js
url = https://github.com/mishoo/UglifyJS.git
45 changes: 43 additions & 2 deletions Jakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,53 @@
var DEPLOY = __dirname + "/pkg/";

desc("runs build");
task('default', ['build'], function () {});

desc("clean");
task('clean', [], function () {
var childProcess = require('child_process');

var cmd = 'rm -rf ' + DEPLOY + ' && ' +
'mkdir ' + DEPLOY;

childProcess.exec(cmd, complete);
}, true);

desc("compiles the source files for all extensions");
task('build', [], function () {
task('build', ['clean'], function () {

var util = require('util'),
fs = require('fs');
fs = require('fs'),
files = [
"lib/Channel.js",
"lib/utils.js",
"lib/exec/blackberry.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 = "";

//include require
output += include("thirdparty/browser-require/require.js");

//include modules
output += include(files, function (file, path) {
return "require.define('" + path.replace(/lib\//, "phonegap/").replace(/\.js$/, '') +
"', function (require, module, exports) {\n" + file + "});\n";
});

//include phonegap
output += include('lib/phonegap.js', function (file, path) {
return "require.define('phonegap'" +
", function (require, module, exports) {\n" + file + "});\n";
});

fs.writeFileSync(__dirname + "/pkg/phonegap.js", output);

util.puts(fs.readFileSync("build/dalek", "utf-8"));
});
1 change: 1 addition & 0 deletions node_modules/uglify-js
Submodule uglify-js added at 4f9773
10 changes: 10 additions & 0 deletions test/smoke.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<script type="text/javascript" src="../pkg/phonegap.js"></script>
</head>
<body>
<div>
So this file is just something to include phonegap.js and play with it. I know right! #EPIC
</div>
</body>
</html>
1 change: 1 addition & 0 deletions thirdparty/browser-require
Submodule browser-require added at 0f1c1f

0 comments on commit fafcf2f

Please sign in to comment.