1
1
"use babel"
2
2
3
- import path from "path"
3
+ import * as path from "path"
4
4
import GrammarUtils from "../grammar-utils"
5
5
const { command } = GrammarUtils
6
6
7
7
const bin = path . join ( __dirname , "../.." , "node_modules" , ".bin" )
8
8
const coffee = path . join ( bin , "coffee" )
9
- const babel = path . join ( bin , "babel" )
9
+ const babel = path . join (
10
+ __dirname ,
11
+ "../.." ,
12
+ "node_modules" ,
13
+ ".bin" ,
14
+ GrammarUtils . OperatingSystem . isWindows ( ) ? "babel-node.cmd" : "babel-node"
15
+ )
10
16
const babelConfig = path . join ( __dirname , "babel.config.js" )
11
17
12
- const args = function ( { filepath } ) {
13
- const cmd = `'${ coffee } ' -p '${ filepath } '|'${ babel } ' --filename '${ filepath } --config-file ${ babelConfig } '| node`
18
+ const rimraf = path . join (
19
+ __dirname ,
20
+ "../.." ,
21
+ "node_modules" ,
22
+ ".bin" ,
23
+ GrammarUtils . OperatingSystem . isWindows ( ) ? "rimraf.cmd" : "rimraf"
24
+ )
25
+
26
+ function coffeeArgs ( { filepath } ) {
27
+ const jsFile = filepath . replace ( path . extname ( filepath ) , ".js" )
28
+ const cmd = `'${ coffee } ' --compile '${ filepath } ' && ${ babel } ${ jsFile } --config-file ${ babelConfig } ' && ${ rimraf } ${ jsFile } `
14
29
return GrammarUtils . formatArgs ( cmd )
15
30
}
16
31
@@ -23,10 +38,10 @@ const CoffeeScript = {
23
38
const lit = scopeName !== null && scopeName . includes ( "lit" ) ? "lit" : ""
24
39
const code = context . getCode ( )
25
40
const filepath = GrammarUtils . createTempFileWithCode ( code , `.${ lit } coffee` )
26
- return args ( { filepath } )
41
+ return coffeeArgs ( { filepath } )
27
42
} ,
28
43
} ,
29
- "File Based" : { command, args } ,
44
+ "File Based" : { command, args : coffeeArgs } ,
30
45
}
31
46
32
47
const CoffeeScriptLiterate = CoffeeScript
0 commit comments