-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
74 lines (55 loc) · 1.62 KB
/
gulpfile.js
File metadata and controls
74 lines (55 loc) · 1.62 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const { simpleGit } = require("simple-git");
const sh = require("shelljs");
async function publishDemo() {
sh.cd(__dirname);
console.log("Cloning remote repository");
sh.rm("-rf", "publish");
sh.exec("git clone https://github.com/netspeak/netspeak.github.io.git publish");
const repo = simpleGit(__dirname + "/publish");
await repo.status(); // verify repo
sh.exec("npm run clean");
sh.exec("npm run build:demo");
sh.rm("-rf", "publish/demo");
sh.mkdir("-p", "publish/demo");
sh.cp("-r", "./public/*", "./publish/demo");
const status = await repo.status();
if (status.files.length === 0) {
console.log("Nothing changed. No commit will be made.");
return;
}
console.log("Commit and push");
await repo.add("*");
await repo.commit("Published demo");
await repo.push();
}
async function publishRelease() {
sh.cd(__dirname);
console.log("Cloning remote repository");
sh.rm("-rf", "publish");
sh.exec("git clone https://github.com/netspeak/netspeak.github.io.git publish");
const repo = simpleGit(__dirname + "/publish");
await repo.status(); // verify repo
sh.exec("npm run clean");
sh.exec("npm run build");
sh.cd("./publish");
sh.ls().forEach(file => {
if (!/^(?:\.git|\.nojekyll|demo|CNAME)$/i.test(file)) {
sh.rm("-rf", file);
}
});
sh.cd("..");
sh.cp("-r", "./public/*", "./publish");
const status = await repo.status();
if (status.files.length === 0) {
console.log("Nothing changed. No commit will be made.");
return;
}
console.log("Commit and push");
await repo.add("*");
await repo.commit("Published release");
await repo.push();
}
module.exports = {
publishDemo,
publishRelease,
};