rsync check

This commit is contained in:
Dragan Filipovic 2022-12-31 10:00:32 +01:00
parent 11f58724d7
commit 5403dab9a0
2 changed files with 21 additions and 15 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -3,21 +3,27 @@ const { exec, execSync } = require("child_process");
const validateRsync = (callback = () => {}) => { const validateRsync = (callback = () => {}) => {
const rsyncCli = commandExists("rsync"); const rsyncCli = commandExists("rsync");
console.log('⚠️ [CLI] Rsync doesn\'t exists. Start installation with "apt-get" \n'); if (rsyncCli) {
if (!rsyncCli) { console.log('⚠️ [CLI] Rsync exists', execSync("rsync --version"));
execSync("sudo apt-get update"); return callback();
exec("sudo apt-get --no-install-recommends install rsync", (err, data, stderr) => {
if (err) {
console.log("⚠️ [CLI] Rsync installation failed. Aborting ... ", err.message);
process.abort();
} else {
console.log("✅ [CLI] Rsync installed. \n", data, stderr);
callback();
}
});
} else {
callback();
} }
console.log('⚠️ [CLI] Rsync doesn\'t exists. Start installation with "apt-get" \n');
try {
execSync("sudo apt-get update");
} catch (e) {
console.log( "⚠️ [CLI] Cant run . apt-get update. Skipping ...". e.message);
}
exec("sudo apt-get --no-install-recommends install rsync", (err, data, stderr) => {
if (err) {
console.log("⚠️ [CLI] Rsync installation failed. Aborting ... ", err.message);
process.abort();
} else {
console.log("✅ [CLI] Rsync installed. \n", data, stderr);
callback();
}
});
}; };
const validateInputs = (inputs) => { const validateInputs = (inputs) => {