File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 66
77export interface TempContext {
88 baseDir : string ;
9+ createFileFromString : (
10+ content : string ,
11+ options ?: Deno . MakeTempOptions ,
12+ ) => string ;
913 createFile : ( options ?: Deno . MakeTempOptions ) => string ;
1014 createDir : ( options ?: Deno . MakeTempOptions ) => string ;
1115 cleanup : ( ) => void ;
Original file line number Diff line number Diff line change @@ -66,8 +66,13 @@ export function createTempContext(options?: Deno.MakeTempOptions): TempContext {
6666
6767 const tempContextCleanupHandlers : VoidFunction [ ] = [ ] ;
6868
69- return {
69+ const result : TempContext = {
7070 baseDir : dir ,
71+ createFileFromString : ( content : string , options ?: Deno . MakeTempOptions ) => {
72+ const file = result . createFile ( options ) ;
73+ Deno . writeTextFileSync ( file , content ) ;
74+ return file ;
75+ } ,
7176 createFile : ( options ?: Deno . MakeTempOptions ) => {
7277 return Deno . makeTempFileSync ( { ...options , dir } ) ;
7378 } ,
@@ -93,6 +98,7 @@ export function createTempContext(options?: Deno.MakeTempOptions): TempContext {
9398 tempContextCleanupHandlers . push ( handler ) ;
9499 } ,
95100 } ;
101+ return result ;
96102}
97103
98104export function systemTempDir ( name : string ) {
You can’t perform that action at this time.
0 commit comments