gitdeploy/html/scripts/watch

34 lines
566 B
Plaintext
Raw Normal View History

2020-09-21 14:34:41 +00:00
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var { exec } = require('child_process');
var cmd = `rsync -av --exclude="**.js" --exclude="css/" --exclude="js/" src/ dist/`;
fs.watch(
'src',
{
recursive: true
},
function (eventType, filename) {
//console.log(eventType, filename);
if (filename.includes('.html')) {
rsync();
}
}
);
function rsync() {
exec(
cmd,
{
path: process.env.PATH,
cwd: process.cwd()
},
function (err, stdout, stderr) {
console.log(stdout);
}
);
}
rsync();