Skip to content
Snippets Groups Projects
Verified Commit c8f23239 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3504265 by finnsky, ksenzee, smustgrave: Yarn watch task broken

parent dcb0e065
Branches
Tags
No related merge requests found
......@@ -9,19 +9,18 @@
'use strict';
const fs = require('node:fs');
const path = require('node:path');
const chokidar = require('chokidar');
const { watch } = require('chokidar');
const { stat, unlink } = require('node:fs');
const changeOrAdded = require('./changeOrAdded');
const log = require('./log');
// Match only on .pcss.css files.
const fileMatch = './**/*.pcss.css';
// Ignore everything in node_modules
const watcher = chokidar.watch(fileMatch, {
// Initialize watcher.
const watcher = watch(['./themes', './modules', './profiles'], {
ignoreInitial: true,
ignored: './node_modules/**'
ignored: (filePath, stats) =>
stats?.isFile() && !filePath.endsWith('.pcss.css') || filePath.includes('node_modules'),
usePolling: true,
});
const unlinkHandler = (err) => {
......@@ -36,8 +35,10 @@ watcher
.on('change', changeOrAdded)
.on('unlink', (filePath) => {
const fileName = filePath.slice(0, -9);
fs.stat(`${fileName}.css`, () => {
fs.unlink(`${fileName}.css`, unlinkHandler);
stat(`${fileName}.css`, (err) => {
if (!err) {
unlink(`${fileName}.css`, unlinkHandler);
}
});
})
.on('ready', () => log(`Watching '${fileMatch}' for changes.`));
.on('ready', () => log(`Watching '**/*.pcss.css' for changes.`));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment