12345678910111213141516171819202122232425262728 |
- const Client = require('node-ssh')
- const ssh = new Client()
- ssh.connect({
- host: process.env.npm_package_remote_host,
- port: '22',
- username: process.env.npm_package_remote_user,
- password: process.env.npm_package_remote_password,
- }).then(() => {
- const failedList = []
- ssh.putDirectory(process.env.npm_package_remote_local, process.env.npm_package_remote_path, {
- recursive: true,
- concurrency: 1,
- tick: function(localPath, remotePath, error) {
- if (error) {
- failedList.push(localPath)
- }
- },
- }).then((status) => {
- if (failedList.length > 0) {
- console.log('发布失败')
- console.log('failed transfers', failedList.join(', '))
- } else {
- console.log(status ? '发布成功' : '发布失败')
- }
- ssh.dispose()
- })
- })
|