-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.js
More file actions
33 lines (26 loc) · 942 Bytes
/
Copy pathupload.js
File metadata and controls
33 lines (26 loc) · 942 Bytes
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
import { env, argv } from "node:process";
import pty from "node-pty";
const { SERVER_USERNAME, SERVER_DEST, SERVER_PASSWORD } = env;
if (argv.includes("--scp")) {
const process = pty.spawn("scp", ["-r", "dist/", `${SERVER_USERNAME}:${SERVER_DEST}`], { env });
process.onExit((e) => {
console.log(`child process exited with code ${e.exitCode} and signal ${e.signal}`);
});
process.onData((data) => {
console.log(data);
if (data.toLowerCase().includes("password:")) {
process.write(`${SERVER_PASSWORD}\n`);
}
});
} else {
const process = pty.spawn("rsync", ["-av", "--delete", "dist/", `${SERVER_USERNAME}:${SERVER_DEST}`], { env });
process.onExit((e) => {
console.log(`child process exited with code ${e.exitCode} and signal ${e.signal}`);
});
process.onData((data) => {
console.log(data);
if (data.includes("password:")) {
process.write(`${SERVER_PASSWORD}\n`);
}
});
}