dirfly 0.6.0 → 0.7.0
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/dist/index.js +18 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
5
|
import path, { basename } from "node:path";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
|
-
import {
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
8
|
var { positionals } = parseArgs({ allowPositionals: true });
|
|
9
9
|
var serverUrlIdx = positionals.findIndex((it) => it.startsWith("svn+ssh://"));
|
|
10
10
|
if (serverUrlIdx === -1)
|
|
@@ -24,10 +24,25 @@ var serverFullUrl = `${serverUrl}/${serverDir}`;
|
|
|
24
24
|
console.log(`准备导入: ${localDir} → ${serverFullUrl}`);
|
|
25
25
|
var cmds = [
|
|
26
26
|
`svn import -m "导入临时占位文件" ${gitignore} ${serverFullUrl}/${gitignore}`,
|
|
27
|
-
`svn checkout
|
|
27
|
+
`svn checkout ${serverFullUrl} .`,
|
|
28
28
|
`svn propset svn:ignore -F ./.gitignore ./`,
|
|
29
29
|
`svn resolve --accept working ./.gitignore`,
|
|
30
30
|
`svn add --force . `,
|
|
31
31
|
`svn commit -m "新增项目${serverDir}"`
|
|
32
32
|
];
|
|
33
|
-
cmds.forEach((cmd) =>
|
|
33
|
+
cmds.forEach((cmd) => {
|
|
34
|
+
const res = crossSpawnExec(cmd, { stdio: "inherit" });
|
|
35
|
+
if (res.status) {
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
function crossSpawnExec(cmd, options) {
|
|
40
|
+
let [bin, ...params] = cmd.trim().split(/\s+/);
|
|
41
|
+
if (!bin)
|
|
42
|
+
throw new Error("执行命令有误");
|
|
43
|
+
if (process.platform === "win32") {
|
|
44
|
+
params.unshift("-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", bin);
|
|
45
|
+
bin = "powershell.exe";
|
|
46
|
+
}
|
|
47
|
+
return spawnSync(bin, params, { stdio: "inherit", ...options });
|
|
48
|
+
}
|