From 223261b739c0fa3ab1061129582ef1b4da5cb450 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 22 Sep 2019 17:50:42 +0800 Subject: [PATCH] --local default to './dist' --- README.md | 13 +++++++------ deploy.js | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f31be41..907ca29 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,14 @@ ## 参数 * -t, --type: web(默认) 或 git * 如果是 git - * -r, --repo: 'https://github.com/ORG/ORG.github.io' - * -b, --branch + * -r, --repo: 远程仓库,例如 'https://github.com/ORG/ORG.github.io' + * -b, --branch: 分支,默认为 master * 如果是 web * -H, --host: 远程主机 - * -P, --port: 端口 - * -D, --dir: 例如 /home/USER/FOLDER - * -d, --dist: 默认为 dist。例如 www -* -l, --local: 本地文件夹,例如 ../../project/public。默认为 dist + * -P, --port: 远程端口,默认为 22 + * -D, --dir: 远程目录,例如 /home/USER/FOLDER + * -d, --dist: 远程文件夹,例如 www。默认为 dist。 +* -l, --local: 本地文件夹,例如 ../../project/public。默认为 ./dist +* -u, --user: 用户名 * -p, --password: 密码 * -k, --key: 密钥文件 diff --git a/deploy.js b/deploy.js index 0f99b25..f409b7d 100644 --- a/deploy.js +++ b/deploy.js @@ -51,7 +51,7 @@ const connection = { dist: commander.dist || Config.deploy.dist || 'dist', // 新系统将发布在这个文件夹里。建议为dist,和npm run build产生的目录一致,这样既可以远程自动部署,也可以直接登录服务器手动部署。 repo: commander.repo || Config.deploy.repo, branch: commander.branch || Config.deploy.branch || 'master', - local: commander.local || Config.deploy.local || 'dist', + local: commander.local || Config.deploy.local || './dist', username: commander.user || Config.deploy.user, privateKey: fs.existsSync(privateKeyFile) ? privateKeyFile : undefined, password: commander.password || Config.deploy.password, @@ -100,7 +100,7 @@ function deployToWeb(){ await ssh.execCommand(`mv ${connection.dist} ${connection.dist}-backup-${new Date().toISOString()}`, { cwd: connection.dir }) console.log(`[ mkdir ${connection.dist} ... ]`) await ssh.execCommand(`mkdir ${connection.dist}`, { cwd: connection.dir }) - const toCreate = necessaryPath('./'+connection.local) + const toCreate = necessaryPath(path.join('./', connection.local)) for (const name of toCreate) { console.log(`[ mkdir ${connection.dist}/${name.join('/')} ... ]`) await ssh.execCommand(`mkdir ${connection.dist}/${name.join('/')}`, { cwd: connection.dir }) @@ -108,7 +108,7 @@ function deployToWeb(){ let err console.log(`[ Upload to ${connection.dir}/${connection.dist} ... ]`) - await ssh.putDirectory('./'+connection.local, `${connection.dir}/${connection.dist}`, { + await ssh.putDirectory(path.join('./', connection.local), `${connection.dir}/${connection.dist}`, { concurrency: 10, recursive: true, validate: itemPath => {