123456789101112131415161718192021222324252627282930313233343536373839 |
- /*
- * @Author: zhangyu
- * @Date: 2019-12-18 16:18:30
- * @Info: 自动化部署
- * @LastEditTime: 2020-05-06 14:48:27
- */
- 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();
- });
- });
|