-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.js
More file actions
36 lines (32 loc) · 1.15 KB
/
Copy pathupdate.js
File metadata and controls
36 lines (32 loc) · 1.15 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
const json5Writer = require("json5-writer");
const fs = require("fs");
const del = require("del");
const newConf = JSON.parse(fs.readFileSync("package.json", "utf-8"));
let oldConf;
if (fs.existsSync("package.json5")) {
oldConf = fs.readFileSync("package.json5", "utf-8");
const writer = json5Writer.load(oldConf);
writer.write(newConf);
fs.writeFileSync("package.json5", writer.toSource({
quote: "double",
trailingComma: false,
quoteKeys: true
}), "utf-8");
} else if (fs.existsSync("package.json")) {
fs.writeFileSync("package.json5", JSON.stringify(newConf), "utf-8");
} else if (fs.existsSync(".packageJsonBack")) {
const getBack = JSON.parse(fs.readFileSync(".packageJsonBack", "utf-8"));
fs.writeFileSync("package.json5", JSON.stringify(".packageJsonBack"), "utf-8");
}
process.exit();
//
// del("./package.json5");
// confWrite = confWrite.replace("x=", "");
// confWrite = confWrite.replace(/'/g, "");
// const CreateFiles = fs.createWriteStream('./package.json5', {
// flags: 'a' //flags: 'a' preserved old data
// });
// CreateFiles.write(confWrite);
// fs.writeFile('package.json5', confWrite);
// )
// ;