File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,17 @@ temp.track()
11
11
const GrammarUtils = {
12
12
tempFilesDir : path . join ( os . tmpdir ( ) , "atom_script_tempfiles" ) ,
13
13
14
+ ensureTempDir ( ) {
15
+ if ( ! fs . existsSync ( this . tempFilesDir ) ) {
16
+ fs . mkdirSync ( this . tempFilesDir )
17
+ }
18
+ } ,
19
+
14
20
// Public: Create a temporary path
15
21
//
16
22
// Returns the {String} filepath of the new file
17
23
createTempPath ( prefix = "" , extension = "" ) {
24
+ this . ensureTempDir ( )
18
25
return temp . path ( { dir : this . tempFilesDir , prefix, suffix : extension } )
19
26
} ,
20
27
@@ -25,6 +32,7 @@ const GrammarUtils = {
25
32
// Returns the {String} filepath of the new file
26
33
createTempFileWithCode ( code , extension = "" ) {
27
34
try {
35
+ this . ensureTempDir ( )
28
36
const tempFile = temp . openSync ( { dir : this . tempFilesDir , suffix : extension } )
29
37
fs . writeSync ( tempFile . fd , code )
30
38
fs . closeSync ( tempFile . fd )
You can’t perform that action at this time.
0 commit comments