Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Commit

Permalink
Also build unminified browser version.
Browse files Browse the repository at this point in the history
Addresses #21.
  • Loading branch information
RubenVerborgh committed Jan 31, 2014
1 parent 555f49a commit d969c88
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions build/build.js
Expand Up @@ -2,16 +2,20 @@
var fs = require("fs");
var UglifyJS = require("uglify-js");

var copyright = fs.readFileSync("promiscuous.js", "utf8").match(/.*\n/)[0];
var minified = copyright + UglifyJS.minify("promiscuous.js").code;
var browserified = minified.replace("module.exports", "Promise")
.replace("setImmediate", "setTimeout");
var full = fs.readFileSync("promiscuous.js", "utf8");
var copyright = full.match(/.*\n/)[0];
var minified = copyright + UglifyJS.minify(full, { fromString: true }).code;
var browserFull = full.replace("module.exports", "window.Promise")
.replace("setImmediate", "setTimeout");
var browser = copyright + UglifyJS.minify(browserFull, { fromString: true }).code
.replace("window.Promise", "Promise");

var path = "dist/";
if(!fs.existsSync(path))
fs.mkdirSync(path);

fs.writeFileSync(path + "promiscuous-node.js", minified);
fs.writeFileSync(path + "promiscuous-browser.js", browserified);
fs.writeFileSync(path + "promiscuous-browser.js", browser);
fs.writeFileSync(path + "promiscuous-browser-full.js", browserFull);
fs.writeFileSync(path + "promiscuous-shim.js",
browserified.replace("!", "(typeof Promise)[0]!='u'||"));
browser.replace("!", "(typeof Promise)[0]!='u'||"));

0 comments on commit d969c88

Please sign in to comment.