Spaces:
Running
Running
File size: 1,416 Bytes
50e5501 e6e06c6 eccbbd1 e0675e2 e6e06c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
console.log("ftp-uploading..............")
const { execSync, exec, spawn } = require("child_process");
const path = require("path");
const repoPath = path.join(__dirname, "dist");
function runWithExecSync() {
return new Promise((resolve, reject) => {
try {
execSync("sh upload.sh", { cwd: repoPath, stdio: "inherit" });
resolve("execSync success");
} catch (err) {
reject(err);
}
});
}
function runWithExec() {
return new Promise((resolve, reject) => {
exec("sh upload.sh", { cwd: repoPath }, (error, stdout, stderr) => {
if (error) {
reject(error);
return;
}
console.log(stdout);
resolve("exec success");
});
});
}
function runWithSpawn() {
return new Promise((resolve, reject) => {
const child = spawn("sh", ["upload.sh"], { cwd: repoPath, stdio: "inherit" });
child.on("close", (code) => {
if (code === 0) {
resolve("spawn success");
} else {
reject(new Error(`spawn exited with code ${code}`));
}
});
});
}
(async () => {
try {
await runWithExecSync();
} catch (e1) {
console.error("execSync failed:", e1);
try {
await runWithExec();
} catch (e2) {
console.error("exec failed:", e2);
try {
await runWithSpawn();
} catch (e3) {
console.error("spawn failed:", e3);
process.exit(1);
}
}
}
})();
|