Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
22 lines
507 B
Plaintext
22 lines
507 B
Plaintext
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
/**
|
|
* Wrapper around `fs.watch` that provides a workaround
|
|
* for https://github.com/nodejs/node/issues/5039.
|
|
*/
|
|
function watchFile(filepath, callback) {
|
|
const directory = path.dirname(filepath);
|
|
const filename = path.basename(filepath);
|
|
return fs.watch(directory, {
|
|
persistent: false,
|
|
recursive: false
|
|
}, (event, changedFilename) => {
|
|
if (changedFilename === filename) {
|
|
callback();
|
|
}
|
|
});
|
|
}
|
|
|
|
export { watchFile as default };
|