From b5223ae17c7b9d54a50c8e49bb6c142ec88d95f3 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 23 Feb 2020 11:06:16 +0800 Subject: [PATCH] change deploy type 'web' to 'ssh' --- .deploy_git | 1 + deploy.js | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 160000 .deploy_git diff --git a/.deploy_git b/.deploy_git new file mode 160000 index 0000000..53affca --- /dev/null +++ b/.deploy_git @@ -0,0 +1 @@ +Subproject commit 53affcafdaefb4873c9975ed65952af630e989ca diff --git a/deploy.js b/deploy.js index 6420a07..3d9862b 100644 --- a/deploy.js +++ b/deploy.js @@ -29,7 +29,7 @@ try { commander .version('1.0', '-v, --version') // 默认是 -V。如果要 -v,就要加 '-v --version' .option('-f, --from ', `from path to copy from. Default to ${Config.deploy.from}`) - .option('-t, --type ', `Deploy to server type, web or git. Default to ${Config.deploy.type}`) + .option('-t, --type ', `Deploy to server type, ssh or git. Default to ${Config.deploy.type}`) .option('-H, --host ', `Host IP or domain name of the target server. Default to ${Config.deploy.host}`) .option('-P, --port ', `Ssh port number of the target server. Default to ${Config.deploy.port}`) .option('-D, --dir ', `Destination path to deploy on the target server. Default to ${Config.deploy.dir}`) @@ -47,7 +47,7 @@ const privateKeyFile = commander.key || Config.deploy.key || `${process.env.HOME const connection = { from: commander.from || Config.deploy.from || './dist', - type: commander.type || Config.deploy.type || 'web', + type: commander.type || Config.deploy.type || 'ssh', host: commander.host || Config.deploy.host, port: commander.port || Config.deploy.port || 22, dir: commander.dir || Config.deploy.dir, // 目标服务器上的目录。似乎该目录必须已经存在于服务器上 @@ -68,14 +68,14 @@ const connection = { } console.log(` connection = ${JSON.stringify(connection)}`) -if (connection.type==='web') { - deployToWeb() +if (connection.type==='ssh') { + deployToSsh() }else if (connection.type==='git'){ deployToGit() } -/** ********************** 连接到 Web主机,拷贝文件到指定路径 ************* **/ -function deployToWeb(){ +/** ********************** 连接到 Ssh主机,拷贝文件到指定路径 ************* **/ +function deployToSsh(){ const ssh = new (require('node-ssh'))() function subDirs (path) {