Skip to content

Commit b298ac0

Browse files
committed
fix: detect literate coffee
1 parent 3466e03 commit b298ac0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/grammars/coffeescript.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ const rimraf = path.join(
2424
)
2525

2626
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}`
27+
let filePathOutput = filepath
28+
const extension = filepath.substring(filepath.indexOf(".") + 1)
29+
filePathOutput = filePathOutput.replace(extension, "js")
30+
const cmd = `'${coffee}' --compile '${filepath}' && ${babel} ${filePathOutput} --config-file ${babelConfig}' && ${rimraf} ${filePathOutput}`
2931
return GrammarUtils.formatArgs(cmd)
3032
}
3133

@@ -35,10 +37,11 @@ const CoffeeScript = {
3537
args(context) {
3638
const editor = atom.workspace.getActiveTextEditor()
3739
const scopeName = editor ? editor.getGrammar().scopeName : null
38-
const lit = scopeName !== null && scopeName.includes("lit") ? "lit" : ""
40+
const isLiterate = scopeName !== null && scopeName.includes("lit")
41+
const lit = isLiterate ? "lit" : ""
3942
const code = context.getCode()
4043
const filepath = GrammarUtils.createTempFileWithCode(code, `.${lit}coffee`)
41-
return coffeeArgs({ filepath })
44+
return coffeeArgs({ filepath, isLiterate })
4245
},
4346
},
4447
"File Based": { command, args: coffeeArgs },

0 commit comments

Comments
 (0)