Skip to content

Commit d4a8eae

Browse files
committed
chore(postcss): avoid file-system race
1 parent 67d797c commit d4a8eae

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

scripts/postcss-css-to-esm.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ function cssToEsmPostcssPlugin(opts) {
4444
// it seems slower to read the old content, but writing the same content with no real changes
4545
// (as in initial build and then watch mode) will cause an unnecessary dev server refresh
4646
let oldContent = '';
47-
if (fs.existsSync(filePath)) {
48-
oldContent = fs.readFileSync(filePath).toString();
47+
try {
48+
oldContent = fs.readFileSync(filePath, 'utf8');
49+
} catch (e) {
50+
if (e.code !== 'ENOENT') {
51+
throw e;
52+
}
4953
}
5054

5155
const content = getTSContent(targetFile, packageName, css, exportTokens);

0 commit comments

Comments
 (0)