Skip to content

Commit 7037bae

Browse files
fix: add a check to fix the generation failed in the parallel execution (#721)
Co-authored-by: AayushSaini101 <[email protected]>
1 parent 7188fbf commit 7037bae

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

hooks/01_removeNotRelevantParts.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const path = require('path');
22
const rimraf = require('rimraf');
3+
const fs = require('fs');
34

45
const callback = (error) => {
56
if (error) {
67
throw error;
78
}
89
};
9-
1010
/**
1111
* Removes unnecessary files (css, js) if user pass `singleFile` parameter.
1212
*/
@@ -21,8 +21,15 @@ module.exports = {
2121
maxBusyTries: 3
2222
};
2323

24-
rimraf.sync(jsDir, opts, callback);
25-
rimraf.sync(cssDir, opts, callback);
24+
// Attempt to delete jsDir if it exists
25+
if (fs.existsSync(jsDir)) {
26+
rimraf.sync(jsDir, opts, callback);
27+
}
28+
29+
// Attempt to delete cssDir if it exists
30+
if (fs.existsSync(cssDir)) {
31+
rimraf.sync(cssDir, opts, callback);
32+
}
2633
}
2734
}
28-
};
35+
};

0 commit comments

Comments
 (0)