@taole/deploy-helper 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +20 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Client } from 'node-scp'
|
|
4
4
|
import fs from 'fs';
|
|
5
|
-
import { join } from "path";
|
|
5
|
+
import { join, basename, dirname } from "path";
|
|
6
6
|
import { simpleGit } from 'simple-git';
|
|
7
7
|
import { homedir } from 'os'
|
|
8
8
|
|
|
@@ -102,7 +102,6 @@ async function main() {
|
|
|
102
102
|
process.exit(0);
|
|
103
103
|
} else if (["scp", "scpevt"].includes(command)) {
|
|
104
104
|
const file = process.argv[3];
|
|
105
|
-
const dest = process.argv[4] || file;
|
|
106
105
|
if (!file) {
|
|
107
106
|
console.log(`file参数不能为空`);
|
|
108
107
|
process.exit(1);
|
|
@@ -114,7 +113,25 @@ async function main() {
|
|
|
114
113
|
console.log(`${srcFilePath}不存在`);
|
|
115
114
|
process.exit(1);
|
|
116
115
|
}
|
|
117
|
-
|
|
116
|
+
if (fs.statSync(srcFilePath).isDirectory()) {
|
|
117
|
+
console.log(`${srcFilePath}是目录, 不支持scp目录`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
// 获取srcFilePath的目录
|
|
121
|
+
const fileDir = dirname(srcFilePath);
|
|
122
|
+
const fileName = basename(srcFilePath);
|
|
123
|
+
const dest = process.argv[4] || fileName;
|
|
124
|
+
if(dest.includes("/") || dest.includes("\\")){
|
|
125
|
+
console.log(`dest不能包含/或\\`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if(workDir !== fileDir){
|
|
130
|
+
console.log(`仅支持scp当前目录下的文件(不带子目录)`);
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const destPath = "/home/web/website/tuwan_www/templets/static/play/" + (command === 'scp' ? '' : 'events/') + dest;
|
|
118
135
|
|
|
119
136
|
const scpClient = await getScpClient();
|
|
120
137
|
console.log(`scp: ${srcFilePath} -> ${destPath}`);
|