Major update: Add Environment variables support

This commit is contained in:
Benjamin Toby
2024-10-16 09:40:21 +01:00
parent ed5248a43f
commit f56a63b2f2
8 changed files with 110 additions and 22 deletions
+1 -3
View File
@@ -2,9 +2,7 @@
// @ts-check
const fs = require("fs");
const path = require("path");
const { execSync, spawn } = require("child_process");
const { spawn } = require("child_process");
const watchFiles = require("./watch/files");
const watchFolders = require("./watch/folders");
+15
View File
@@ -111,6 +111,14 @@ function sync({ options, filePath, files }) {
const dstFl = destFiles[j];
if (typeof dstFl == "string") {
if (!fs.existsSync(dstFl)) continue;
if (filePath === dstFl) {
console.log(
`You can't sync the same paths. Please check your configuration and resolve duplicate paths`
);
process.exit(6);
}
cmdArray.push(filePath, dstFl);
const cmd = cmdArray.join(" ");
execSync(cmd, {
@@ -119,6 +127,13 @@ function sync({ options, filePath, files }) {
} else if (dstFl.path) {
if (!dstFl.host && !fs.existsSync(dstFl.path)) continue;
if (filePath === dstFl.path) {
console.log(
`You can't sync the same paths. Please check your configuration and resolve duplicate paths`
);
process.exit(6);
}
if (dstFl.host && dstFl.ssh_key && dstFl.user) {
cmdArray.push("-e", `'ssh -i ${dstFl.ssh_key}'`);
cmdArray.push(
+15
View File
@@ -120,6 +120,14 @@ function sync({ options, dirs, dirPath, init }) {
const dstDr = dstDirs[j];
if (typeof dstDr == "string") {
if (!fs.existsSync(dstDr)) continue;
if (dirPath === dstDr) {
console.log(
`You can't sync the same paths. Please check your configuration and resolve duplicate paths`
);
process.exit(6);
}
cmdArray.push(
path.normalize(dirPath) + "/",
path.normalize(dstDr) + "/"
@@ -131,6 +139,13 @@ function sync({ options, dirs, dirPath, init }) {
} else if (dstDr.path) {
if (!dstDr.host && !fs.existsSync(dstDr.path)) continue;
if (dirPath === dstDr.path) {
console.log(
`You can't sync the same paths. Please check your configuration and resolve duplicate paths`
);
process.exit(6);
}
if (dstDr.host && dstDr.ssh_key && dstDr.user) {
cmdArray.push("-e", `'ssh -i ${dstDr.ssh_key}'`);
cmdArray.push(