forked from accforgit/blog-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 886 Bytes
/
index.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
const execSync = require('child_process').execSync
const fs = require('fs')
const cmd1 = 'git init'
let cmd2 = 'git remote add -f origin '
const cmd3 = 'git config core.sparsecheckout true'
const cmd4 = 'git pull origin master'
let path = ''
process.stdin.setEncoding('utf8')
process.stdout.write('请输入仓库远程地址,以及想要复制的文件路径?两个输入以及多个路径都用空格分开:\n')
process.stdin.on('data', data => {
console.log(data)
cmd2 += data.split(' ')[0]
path = data.slice(data.indexOf(' ') + 1).split(' ').join('\n')
process.stdin.emit('end')
})
process.stdin.on('end', () => {
execSync(cmd1)
console.log('完成度:25%')
execSync(cmd2)
console.log('完成度:50%')
execSync(cmd3)
console.log('完成度:75%')
fs.writeFileSync('./.git/info/sparse-checkout', path)
execSync(cmd4)
console.log('It\'s ok!')
})