|
@@ -24,7 +24,7 @@ const { execSync } = require("child_process");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function upServer() {
|
|
|
+ async function upServer() {
|
|
|
const config = {
|
|
|
path: {
|
|
|
// 远程地址
|
|
@@ -44,26 +44,21 @@ const { execSync } = require("child_process");
|
|
|
},
|
|
|
};
|
|
|
const sftp = new client();
|
|
|
- sftp
|
|
|
- .connect(config.romote)
|
|
|
- .then(() => {
|
|
|
- console.log("连接成功,删除中... ");
|
|
|
- return sftp.rmdir(config.path.romotePath, true);
|
|
|
- })
|
|
|
- .then(() => {
|
|
|
- console.log("上传中... ");
|
|
|
- return sftp.uploadDir(config.path.localPath, config.path.romotePath);
|
|
|
- })
|
|
|
- .then(data => {
|
|
|
- console.log("上传完成", data);
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.log("出错了!!", err);
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
+ try{
|
|
|
+ await sftp.connect(config.romote);
|
|
|
+ await sftp.rmdir(config.path.romotePath + '/css', true);
|
|
|
+ await sftp.rmdir(config.path.romotePath + '/fonts', true);
|
|
|
+ await sftp.rmdir(config.path.romotePath + '/js', true);
|
|
|
+ await sftp.rmdir(config.path.romotePath + '/index.html', true);
|
|
|
+ console.log("已清空原有文件");
|
|
|
+ // await sftp.uploadDir(config.path.localPath, config.path.romotePath);
|
|
|
+ // console.log("上传完成");
|
|
|
// 断开连接
|
|
|
sftp.end();
|
|
|
- });
|
|
|
+ console.log("断开链接");
|
|
|
+ }catch(err){
|
|
|
+ console.log("更新失败",err);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -84,7 +79,7 @@ const { execSync } = require("child_process");
|
|
|
execFun();
|
|
|
try {
|
|
|
await getFiles(dirPath);
|
|
|
- upServer();
|
|
|
+ await upServer();
|
|
|
console.log("获取文件路径---完成");
|
|
|
} catch (err) {
|
|
|
console.log("数据上传oss---失败");
|