-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.cjs
47 lines (43 loc) · 857 Bytes
/
deploy.cjs
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
41
42
43
44
45
46
47
const path = require('path')
const { NodeSSH } = require('node-ssh')
const config = require('./config.json')
const { platform } = process
const {
filename,
host,
username,
rsaPathObj,
localPathObj,
remotePath,
shellPath,
shellName,
} = config
const rsaPath = rsaPathObj[platform]
const localPath = localPathObj[platform]
const ssh = new NodeSSH()
!(async function main() {
try {
await ssh.connect({
host,
username,
privateKey: rsaPath,
})
console.log('ssh连接成功')
await ssh.putFiles([
{
local: path.join(filename),
remote: `${remotePath}${filename}`,
},
])
console.log(`${filename} 上传成功`)
} catch (err) {
console.log('ssh连接失败')
console.log(err)
} finally {
exit()
}
})()
function exit() {
ssh.dispose()
process.exit(0)
}