UNPKG

slidev-addon-sm

Version:

slidev-addon slidev sm

52 lines (44 loc) 1.01 kB
import client from "scp2"; import readline from "readline"; import { Writable } from "stream"; const args = process.argv; const srcPath = args[2]; const dstPath = args[3]; console.log(srcPath + " ==> " + dstPath); const fabu = (passwd) => { client.scp( srcPath, { host: "noicoding.cn", port: 22, username: "root", password: passwd, path: dstPath, }, (err) => { if (err) { console.error("更新失败", err); } else { console.log("更新成功"); } } ); }; var mutableStdout = new Writable({ write: function(chunk, encoding, callback) { if (!this.muted) process.stdout.write(chunk, encoding); callback(); } }); mutableStdout.muted = false; var rl = readline.createInterface({ input: process.stdin, output: mutableStdout, terminal: true }); rl.question('Password: ', function(pwd) { fabu(pwd); rl.close(); }); mutableStdout.muted = true;