Skip to content

Commit

Permalink
fix: use babel-node for CoffeeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 22, 2021
1 parent 8581f8e commit 3466e03
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 977 deletions.
27 changes: 21 additions & 6 deletions lib/grammars/coffeescript.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
"use babel"

import path from "path"
import * as path from "path"
import GrammarUtils from "../grammar-utils"
const { command } = GrammarUtils

const bin = path.join(__dirname, "../..", "node_modules", ".bin")
const coffee = path.join(bin, "coffee")
const babel = path.join(bin, "babel")
const babel = path.join(
__dirname,
"../..",
"node_modules",
".bin",
GrammarUtils.OperatingSystem.isWindows() ? "babel-node.cmd" : "babel-node"
)
const babelConfig = path.join(__dirname, "babel.config.js")

const args = function ({ filepath }) {
const cmd = `'${coffee}' -p '${filepath}'|'${babel}' --filename '${filepath} --config-file ${babelConfig}'| node`
const rimraf = path.join(
__dirname,
"../..",
"node_modules",
".bin",
GrammarUtils.OperatingSystem.isWindows() ? "rimraf.cmd" : "rimraf"
)

function coffeeArgs({ filepath }) {
const jsFile = filepath.replace(path.extname(filepath), ".js")
const cmd = `'${coffee}' --compile '${filepath}' && ${babel} ${jsFile} --config-file ${babelConfig}' && ${rimraf} ${jsFile}`
return GrammarUtils.formatArgs(cmd)
}

Expand All @@ -23,10 +38,10 @@ const CoffeeScript = {
const lit = scopeName !== null && scopeName.includes("lit") ? "lit" : ""
const code = context.getCode()
const filepath = GrammarUtils.createTempFileWithCode(code, `.${lit}coffee`)
return args({ filepath })
return coffeeArgs({ filepath })
},
},
"File Based": { command, args },
"File Based": { command, args: coffeeArgs },
}

const CoffeeScriptLiterate = CoffeeScript
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"test": "atom --test spec"
},
"dependencies": {
"@babel/cli": "^7.13.10",
"@babel/core": "^7.13.10",
"@babel/node": "^7.13.12",
"@babel/preset-env": "^7.13.10",
Expand Down
Loading

0 comments on commit 3466e03

Please sign in to comment.