-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-version.js
More file actions
39 lines (33 loc) · 1.02 KB
/
sync-version.js
File metadata and controls
39 lines (33 loc) · 1.02 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
const fs = require('fs');
const { join } = require('path');
const { execSync } = require("child_process");
const root = join(__dirname, './package.json');
const lib = join(__dirname, './projects/angular-ui/package.json');
// css scope
// get version
const rowData = fs.readFileSync(root);
const version = JSON.parse(rowData).version;
const syncVersion = (file, version) => {
console.log(`version`, version)
const data = JSON.parse(fs.readFileSync(file));
data.version = version;
fs.writeFileSync(file, JSON.stringify(data, null, 4));
}
syncVersion(lib, version);
// // commit and push
const envolkSync = (command) => {
execSync(command, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`${command}: ${stdout}`);
});
}
envolkSync("git add .");
envolkSync(`git commit -m "npm release"`);
envolkSync(`git tag v${version} -a -m "auto tagging v${version} by npm"`);