Skip to content

Commit 3466e03

Browse files
committed
fix: use babel-node for CoffeeScript
1 parent 8581f8e commit 3466e03

File tree

3 files changed

+33
-977
lines changed

3 files changed

+33
-977
lines changed

lib/grammars/coffeescript.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
"use babel"
22

3-
import path from "path"
3+
import * as path from "path"
44
import GrammarUtils from "../grammar-utils"
55
const { command } = GrammarUtils
66

77
const bin = path.join(__dirname, "../..", "node_modules", ".bin")
88
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+
)
1016
const babelConfig = path.join(__dirname, "babel.config.js")
1117

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}`
1429
return GrammarUtils.formatArgs(cmd)
1530
}
1631

@@ -23,10 +38,10 @@ const CoffeeScript = {
2338
const lit = scopeName !== null && scopeName.includes("lit") ? "lit" : ""
2439
const code = context.getCode()
2540
const filepath = GrammarUtils.createTempFileWithCode(code, `.${lit}coffee`)
26-
return args({ filepath })
41+
return coffeeArgs({ filepath })
2742
},
2843
},
29-
"File Based": { command, args },
44+
"File Based": { command, args: coffeeArgs },
3045
}
3146

3247
const CoffeeScriptLiterate = CoffeeScript

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"test": "atom --test spec"
2020
},
2121
"dependencies": {
22-
"@babel/cli": "^7.13.10",
2322
"@babel/core": "^7.13.10",
2423
"@babel/node": "^7.13.12",
2524
"@babel/preset-env": "^7.13.10",

0 commit comments

Comments
 (0)