forked from sinonjs/sinon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
executable file
·41 lines (32 loc) · 971 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node
"use strict";
var fs = require("fs");
var browserify = require("browserify");
var pkg = require("./package.json");
// YYYY-MM-DD
var date = new Date().toISOString().split("T")[0];
// Keep the preamble on one line to retain source maps
var preamble = "/* Sinon.JS " + pkg.version + ", " + date
+ ", @license BSD-3 */";
try {
fs.mkdirSync("pkg");
} catch (ignore) {
// We seem to have it already
}
function makeBundle(name, config) {
// Create a UMD wrapper and install the "sinon" global:
config.standalone = "sinon";
browserify("./lib/sinon.js", config)
.bundle(function (err, buffer) {
if (err) {
throw err;
}
var script = preamble + buffer.toString();
fs.writeFile("pkg/" + name + ".js", script);
});
}
makeBundle("sinon", {
// Add inline source maps to the default bundle
debug: true
});
makeBundle("sinon-no-sourcemaps", {});