File tree Expand file tree Collapse file tree 3 files changed +5
-3
lines changed Expand file tree Collapse file tree 3 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,9 @@ export class DirectoryProvider {
4141 return join ( this . temporaryPath , `${ filename } -${ Date . now ( ) } .json` )
4242 }
4343
44- createTemporaryFile < T > ( filename : string , data : T ) {
44+ createTemporaryFile < T > ( filename : string , data : T | null ) {
45+ if ( ! data ) return
46+
4547 const file = this . temporaryFilePath ( filename )
4648 const writer = new Writer ( file )
4749 const parsedData =
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ export class AsyncWriter<T> extends BaseWriter<T> implements AsyncAdapter<T> {
3535 async reset ( initialData : T ) : Promise < void > {
3636 try {
3737 const data = await this . read ( )
38- await this . directory . createTemporaryFile ( this . name , data ) . writeAsync ( )
38+ await this . directory . createTemporaryFile ( this . name , data ) ? .writeAsync ( )
3939 await this . write ( initialData )
4040 } catch ( err ) {
4141 if ( ( err as NodeJS . ErrnoException ) . code === 'ENOENT' ) {
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ export class SyncWriter<T> extends BaseWriter<T> implements SyncAdapter<T> {
3535 reset ( initialData : T ) : void {
3636 try {
3737 const data = this . read ( )
38- this . directory . createTemporaryFile ( this . name , data ) . write ( )
38+ this . directory . createTemporaryFile ( this . name , data ) ? .write ( )
3939 this . write ( initialData )
4040 } catch ( err ) {
4141 throw err
You can’t perform that action at this time.
0 commit comments