-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpush.js
39 lines (34 loc) · 1.1 KB
/
push.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
const fs = require('fs')
const { execSync } = require('child_process')
let readline = require('readline')
let version = require('./package.json').version
let oldVersion = version.trim()
let parts = version.trim().split('.')
parts[2] = parseInt(parts[2]) + 1
let newVersion = parts.join('.')
let replaceFile = [
'./package.json'
]
replaceFile.forEach(file => {
let data = fs.readFileSync(__dirname + '/' + file, {
encoding: 'utf-8'
})
let reg = new RegExp(oldVersion, "g");
let result = data.replace(reg, newVersion);
fs.writeFileSync(__dirname + '/' + file, result, {
encoding: 'utf-8'
})
console.log(file + ': 替换成功');
})
// 创建readline接口实例
let rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("请输入git commit: ", (answer) => {
console.log(execSync('git add .', { encoding: 'utf-8'}))
console.log(execSync(`git commit -am "${answer}"`, { encoding: 'utf-8'}))
console.log(execSync('git push origin master', { encoding: 'utf-8'}))
console.log(execSync('git push coding master', { encoding: 'utf-8'}))
rl.close();
})