mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2025-06-22 04:22:10 +10:00
[code] split helpers into separate files
This commit is contained in:
parent
9cdc72374b
commit
460751d7c3
4 changed files with 180 additions and 141 deletions
42
src/rsyncCli.js
Normal file
42
src/rsyncCli.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
const { sync: commandExists } = require('command-exists');
|
||||
const { get: nodeCmd } = require('node-cmd');
|
||||
|
||||
const validateRsync = (callback = () => {}) => {
|
||||
const rsyncCli = commandExists.sync('rsync');
|
||||
|
||||
if (!rsyncCli) {
|
||||
nodeCmd(
|
||||
'sudo apt-get --no-install-recommends install rsync',
|
||||
(err, data, stderr) => {
|
||||
if (err) {
|
||||
console.log('⚠️ [CLI] Rsync installation failed ', err.message);
|
||||
process.abort();
|
||||
} else {
|
||||
console.log('✅ [CLI] Rsync installed. \n', data, stderr);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
const validateInputs = (inputs) => {
|
||||
const validInputs = inputs.filter((input) => {
|
||||
if (!input) {
|
||||
console.error(`⚠️ ${input} is mandatory`);
|
||||
}
|
||||
|
||||
return input;
|
||||
});
|
||||
|
||||
if (validInputs.length !== inputs.length) {
|
||||
process.abort();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validateRsync,
|
||||
validateInputs
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue