gitdeploy/html/scripts/watch

36 lines
579 B
Plaintext
Raw Permalink Normal View History

2020-09-21 14:34:41 +00:00
#!/usr/bin/env node
2020-10-01 15:11:34 +00:00
"use strict";
2020-09-21 14:34:41 +00:00
2020-10-01 15:11:34 +00:00
var fs = require("fs");
var { exec } = require("child_process");
2020-09-21 14:34:41 +00:00
fs.watch(
2020-10-01 15:11:34 +00:00
"src",
2020-09-21 14:34:41 +00:00
{
2020-10-01 15:11:34 +00:00
recursive: true,
2020-09-21 14:34:41 +00:00
},
function (eventType, filename) {
2020-10-01 15:11:34 +00:00
if (filename.includes(".html")) {
copy().then(function () {
console.log("copied html");
});
2020-09-21 14:34:41 +00:00
}
}
);
2020-10-01 15:11:34 +00:00
async function copy() {
return new Promise(function (resolve) {
exec(
"scripts/copy",
{
path: process.env.PATH,
cwd: process.cwd(),
},
function (err, stdout, stderr) {
resolve();
}
);
});
2020-09-21 14:34:41 +00:00
}
2020-10-01 15:11:34 +00:00
copy();