Skip to content

Commit

Permalink
Build: add new build script
Browse files Browse the repository at this point in the history
fix #16
fix #21
fix #22
  • Loading branch information
fcarstens committed Aug 21, 2015
1 parent 52be3c2 commit e6e7d39
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
27 changes: 27 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var mkdirp = require("mkdirp");
var esperanto = require("esperanto");
var fs = require("fs");
var babel = require("babel");
var pkg = require("./package.json");

mkdirp.sync("dist");

esperanto.bundle({
base: "lib",
entry: "index.js"
}).then(function (bundle) {
var umd = bundle.toUmd({
name: "JsReporters"
});

var transformed = babel.transform(umd.code, {
blacklist: [
"useStrict"
]
});
var license = fs.readFileSync("lib/license-header.js", {encoding: "utf8"})
.replace("@VERSION", pkg.version)
.replace("@DATE", ( new Date() ).toISOString().replace(/:\d+\.\d+Z$/, "Z"));
var content = license + "(function() {\n" + transformed.code + "\n})();";
fs.writeFileSync("dist/js-reporters.js", content);
}).catch(console.error);
10 changes: 10 additions & 0 deletions lib/license-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*!
* JS Reporters @VERSION
* https://github.com/js-reporters
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: @DATE
*/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "js-reporters",
"version": "1.0.0",
"scripts": {
"build": "mkdirp dist/ && esperanto -b -i lib/index.js -t umd --name JsReporters | babel -o dist/js-reporters.js --blacklist strict -m umd",
"build": "node build.js",
"lint": "eslint lib/ test/",
"test": "node test/test.js"
},
Expand Down

0 comments on commit e6e7d39

Please sign in to comment.