generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.js
45 lines (40 loc) · 978 Bytes
/
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
const fs = require("fs");
const path = require("path");
// for building and release the package
// bump version
const bump = (version) => {
const packagePath = path.resolve(__dirname, "package.json");
const package = require(packagePath);
package.version = version;
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2));
console.log("bumped version to " + version);
};
// build
const build = () => {
// nothing here yet
};
const publish = () => {
// publish to npm
const execSync = require("child_process").execSync;
execSync("npm publish --verbose", { stdio: [0, 1, 2] });
console.log("published to npm");
};
// main
const main = () => {
const args = process.argv.slice(2);
const version = args[0];
if (!version) {
console.error("version is required");
process.exit(1);
}
try {
bump(version);
build();
publish();
console.log("done");
} catch (e) {
console.error(e);
process.exit(1);
}
};
main();