@@ -82,6 +82,11 @@ export function createContext(options: Options = {}, root = process.cwd()) {
8282
8383 const writeConfigFilesThrottled = throttle ( 500 , writeConfigFiles , { noLeading : false } )
8484
85+ async function writeFile ( filePath : string , content : string ) {
86+ await fs . mkdir ( dirname ( filePath ) , { recursive : true } )
87+ return await fs . writeFile ( filePath , content , 'utf-8' )
88+ }
89+
8590 let lastDTS : string | undefined
8691 let lastESLint : string | undefined
8792 async function writeConfigFiles ( ) {
@@ -91,7 +96,7 @@ export function createContext(options: Options = {}, root = process.cwd()) {
9196 generateDTS ( dts ) . then ( ( content ) => {
9297 if ( content !== lastDTS ) {
9398 lastDTS = content
94- return fs . writeFile ( dts , content , 'utf-8' )
99+ return writeFile ( dts , content )
95100 }
96101 } ) ,
97102 )
@@ -101,7 +106,7 @@ export function createContext(options: Options = {}, root = process.cwd()) {
101106 generateESLint ( ) . then ( ( content ) => {
102107 if ( content !== lastESLint ) {
103108 lastESLint = content
104- return fs . writeFile ( eslintrc . filepath ! , content , 'utf-8' )
109+ return writeFile ( eslintrc . filepath ! , content )
105110 }
106111 } ) ,
107112 )
0 commit comments