Run add_omni_file script when file change detected

This commit is contained in:
Tom Najdek 2022-05-25 19:56:23 +02:00
parent 7aa3bde170
commit 8b76bf6e65
No known key found for this signature in database
GPG key ID: EEC61A7B4C667D77
7 changed files with 86 additions and 34 deletions

View file

@ -11,11 +11,12 @@ const sassRender = universalify.fromCallback(sass.render);
const ROOT = path.resolve(__dirname, '..');
async function getSass(source, options, signatures={}) {
async function getSass(source, options, signatures = {}) {
const t1 = Date.now();
const files = await globby(source, Object.assign({ cwd: ROOT }, options));
const totalCount = files.length;
var count = 0, shouldRebuild = false;
const outFiles = [];
var shouldRebuild = false;
for (const f of files) {
// if any file changed, rebuild all onSuccess
@ -54,7 +55,7 @@ async function getSass(source, options, signatures={}) {
await fs.outputFile(`${dest}.map`, sass.map);
onProgress(f, dest, 'sass');
signatures[f] = newFileSignature;
count++;
outFiles.push(dest);
}
catch (err) {
throw new Error(`Failed on ${f}: ${err}`);
@ -65,7 +66,8 @@ async function getSass(source, options, signatures={}) {
const t2 = Date.now();
return {
action: 'sass',
count,
count: outFiles.length,
outFiles,
totalCount,
processingTime: t2 - t1
};