|
1 |
| -module.exports = |
| 1 | +path = require 'path' |
| 2 | +GrammarUtils = require '../grammar-utils' |
2 | 3 |
|
3 |
| - CoffeeScript: |
4 |
| - 'Selection Based': |
5 |
| - command: 'coffee' |
6 |
| - args: (context) -> ['--transpile', '-e', context.getCode()] |
| 4 | +bin = path.join __dirname, '../..', 'node_modules', '.bin' |
| 5 | +coffee = path.join bin, 'coffee' |
| 6 | +babel = path.join bin, 'babel' |
7 | 7 |
|
8 |
| - 'File Based': |
9 |
| - command: 'coffee' |
10 |
| - args: ({filepath}) -> ['-t', filepath] |
| 8 | +args = ({filepath}) -> ['-c', "'#{coffee}' -p '#{filepath}'|'#{babel}' --filename '#{bin}'| node"] |
11 | 9 |
|
12 |
| - 'CoffeeScript (Literate)': |
| 10 | +exports.CoffeeScript = |
| 11 | + 'Selection Based': |
| 12 | + command: 'bash' |
| 13 | + args: (context) -> |
| 14 | + {scopeName} = atom.workspace.getActiveTextEditor()?.getGrammar() |
| 15 | + lit = if scopeName?.includes 'lit' then 'lit' else '' |
| 16 | + code = context.getCode() |
| 17 | + filepath = GrammarUtils.createTempFileWithCode(code, ".#{lit}coffee") |
| 18 | + return args({filepath}) |
13 | 19 |
|
14 |
| - 'Selection Based': |
15 |
| - command: 'coffee' |
16 |
| - args: (context) -> ['-t', '-e', context.getCode()] |
| 20 | + 'File Based': { command: 'bash', args } |
17 | 21 |
|
18 |
| - 'File Based': |
19 |
| - command: 'coffee' |
20 |
| - args: ({filepath}) -> ['-t', filepath] |
| 22 | +exports['CoffeeScript (Literate)'] = exports.CoffeeScript |
21 | 23 |
|
22 |
| - IcedCoffeeScript: |
23 |
| - 'Selection Based': |
24 |
| - command: 'iced' |
25 |
| - args: (context) -> ['-e', context.getCode()] |
| 24 | +exports.IcedCoffeeScript = |
| 25 | + 'Selection Based': |
| 26 | + command: 'iced' |
| 27 | + args: (context) -> ['-e', context.getCode()] |
26 | 28 |
|
27 |
| - 'File Based': |
28 |
| - command: 'iced' |
29 |
| - args: ({filepath}) -> [filepath] |
| 29 | + 'File Based': |
| 30 | + command: 'iced' |
| 31 | + args: ({filepath}) -> [filepath] |
0 commit comments