-
Notifications
You must be signed in to change notification settings - Fork 12
/
release.js
78 lines (66 loc) · 1.52 KB
/
release.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
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
75
76
77
78
/* from https://github.com/uswds/uswds/blob/develop/config/gulp/release.js */
const del = require("del");
const spawn = require("cross-spawn");
const gulp = require("gulp");
const dutil = require("./doc-util");
const task = "release";
gulp.task("make-tmp-directory", () => {
dutil.logMessage(
"make-tmp-directory",
"Creating temporary release directory."
);
return gulp.src("src/**/*").pipe(gulp.dest(dutil.dirName));
});
gulp.task("clean-tmp-directory", () => {
dutil.logMessage(
"clean-tmp-directory",
"Deleting temporary release directory."
);
return del(dutil.dirName);
});
gulp.task("zip-archives", done => {
const zip = spawn("zip", [
"--log-info",
"-r",
`./${dutil.dirName}.zip`,
dutil.dirName,
'-x "*.DS_Store"'
]);
dutil.logMessage(
"zip-archives",
`Creating a zip archive in ${dutil.dirName}.zip`
);
zip.stdout.on("data", data => {
if (/[\w\d]+/.test(data)) {
dutil.logData("zip-archives", data);
}
});
zip.stderr.on("data", data => {
dutil.logError("zip-archives", data);
});
zip.on("error", error => {
dutil.logError("zip-archives", "Failed to create a zip archive");
done(error);
});
zip.on("close", code => {
if (code === 0) {
done();
}
});
});
gulp.task(
task,
gulp.series(
done => {
dutil.logMessage(
task,
`Creating a zip archive at ${dutil.dirName}.zip`
);
done();
},
"init",
"make-tmp-directory",
"zip-archives",
"clean-tmp-directory"
)
);