Skip to content

Instantly share code, notes, and snippets.

@anatolinicolae
Last active October 4, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anatolinicolae/ce7128b3d1166843cdfb89dbaeb8428d to your computer and use it in GitHub Desktop.
Save anatolinicolae/ce7128b3d1166843cdfb89dbaeb8428d to your computer and use it in GitHub Desktop.
Sync source to dest with excludes
#!/usr/bin/env node
const exec = require('child_process').exec
let source = process.argv[2]
let destination = process.argv[3]
let command = `rsync -avz `
for (let i = 4; i < process.argv.length; i++) {
command += `--exclude "${process.argv[i]}" `
}
command += `${source} ${destination}`
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`)
return
}
console.log(`stdout: ${stdout}`)
console.log(`stderr: ${stderr}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment