File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 11import path from 'path' ;
2- import fs from 'fs-extra' ;
2+ import fs from 'fs' ;
3+ import { outputFile } from '../utils/fs.js' ;
34
45class SaveResourceToFileSystemPlugin {
56 apply ( registerAction ) {
@@ -20,13 +21,13 @@ class SaveResourceToFileSystemPlugin {
2021 registerAction ( 'saveResource' , async ( { resource} ) => {
2122 const filename = path . join ( absoluteDirectoryPath , resource . getFilename ( ) ) ;
2223 const text = resource . getText ( ) ;
23- await fs . outputFile ( filename , text , { encoding : resource . getEncoding ( ) } ) ;
24+ await outputFile ( filename , text , resource . getEncoding ( ) ) ;
2425 loadedResources . push ( resource ) ;
2526 } ) ;
2627
2728 registerAction ( 'error' , async ( ) => {
2829 if ( loadedResources . length > 0 ) {
29- await fs . remove ( absoluteDirectoryPath ) ;
30+ fs . rmSync ( absoluteDirectoryPath , { force : true , recursive : true } ) ;
3031 }
3132 } ) ;
3233 }
Original file line number Diff line number Diff line change 1+ import path from 'path' ;
2+ import fs from 'fs/promises' ;
3+
4+ async function outputFile ( file , data , encoding ) {
5+ const dir = path . dirname ( file ) ;
6+ await fs . mkdir ( dir , { recursive : true } ) ;
7+
8+ return fs . writeFile ( file , data , { encoding : encoding } ) ;
9+ }
10+
11+ export {
12+ outputFile
13+ } ;
Original file line number Diff line number Diff line change 4040 "cheerio" : " ^1.1.2" ,
4141 "css-url-parser" : " ^1.0.0" ,
4242 "debug" : " ^4.3.1" ,
43- "fs-extra" : " ^11.1.0" ,
4443 "got" : " ^14.4.7" ,
4544 "normalize-url" : " ^8.0.0" ,
4645 "p-queue" : " ^9.0.0" ,
5049 "devDependencies" : {
5150 "c8" : " ^10.0.0" ,
5251 "eslint" : " ^8.5.0" ,
52+ "fs-extra" : " ^11.1.0" ,
5353 "mocha" : " ^11.0.1" ,
5454 "nock" : " ^14.0.0" ,
5555 "should" : " ^13.2.3" ,
You can’t perform that action at this time.
0 commit comments