-
Notifications
You must be signed in to change notification settings - Fork 11
/
make
46 lines (35 loc) · 1.16 KB
/
make
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
42
43
44
45
46
require("shelljs/make");
var archiver = require("archiver"),
fs = require("fs"),
path = require("path"),
Mustache = require("mustache"),
pkg = require("./package.json"),
config = require("./config.json");
config.version = pkg.version;
config.repository = pkg.repository;
target.all = function() {
target.gulp();
};
target.gulp = function() {
createPackage("Gulp")
.append(runMustache("Gulp/_Gulpfile.js", config), { name: "Gulpfile.js" })
.append(runMustache("Gulp/_package.json", config), { name: "package.json" })
.finalize();
};
function createPackage(distname) {
mkdir("-p", "dist");
var output = fs.createWriteStream(path.join("dist", distname) + ".zip");
var archive = archiver("zip", {});
output.on("close", function() {
console.log("Written %d bytes to %s", archive.pointer(), output.path);
});
output.on("error", function(err) {
console.error("Error: %s", err.toString());
});
archive.pipe(output);
return archive;
}
function runMustache(path, vars) {
var fileText = fs.readFileSync(path, { encoding: "utf8" });
return Mustache.render(fileText, vars);
}