-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathUpdateDevVersion.js
More file actions
40 lines (38 loc) · 1.28 KB
/
Copy pathUpdateDevVersion.js
File metadata and controls
40 lines (38 loc) · 1.28 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
const fs = require("fs");
const path = require("path");
const exec = require("child_process").exec;
const process = require("process");
const PACKAGE_JSON_PATH = path.resolve(__dirname, "../package.json");
const CMD = "npm view @ladybugdb/core@next version";
(() => {
exec(CMD, (error, stdout, _) => {
if (error) {
console.error(`Failed to get latest dev version: ${error}`);
process.exit(1);
}
const latestVersion = stdout.trim();
console.log(`Latest dev version is ${latestVersion}`);
fs.readFile(PACKAGE_JSON_PATH, "utf8", (err, data) => {
console.log("Opened package.json at", PACKAGE_JSON_PATH);
if (err) {
console.error("Error reading package.json", err);
process.exit(1);
}
const packageJson = JSON.parse(data);
packageJson.dependencies["@ladybugdb/core"] = `${latestVersion}`;
packageJson.dependencies["@ladybugdb/wasm-core"] = `${latestVersion}`;
fs.writeFile(
PACKAGE_JSON_PATH,
JSON.stringify(packageJson, null, 2),
(err) => {
if (err) {
console.error("Error writing package.json", err);
process.exit(1);
}
console.log(`Updated ladybug to ${latestVersion}`);
process.exit(0);
}
);
});
});
})();