|
1 | 1 | 'use babel';
|
2 | 2 |
|
| 3 | +import path from 'path'; |
3 | 4 | import GrammarUtils from '../grammar-utils';
|
4 | 5 |
|
5 |
| -export default { |
6 |
| - 'Babel ES6 JavaScript': { |
7 |
| - 'Selection Based': { |
8 |
| - command: 'babel-node', |
9 |
| - args: context => ['-e', context.getCode()], |
10 |
| - }, |
11 |
| - 'File Based': { |
12 |
| - command: 'babel-node', |
13 |
| - args: context => [context.filepath], |
| 6 | +const babel = path.join(__dirname, '../..', 'node_modules', '.bin', 'babel'); |
| 7 | + |
| 8 | +const args = ({ filepath }) => ['-c', `${babel} --filename '${babel}' < '${filepath}'| node`]; |
| 9 | + |
| 10 | +exports.Dart = { |
| 11 | + 'Selection Based': { |
| 12 | + command: 'dart', |
| 13 | + args: (context) => { |
| 14 | + const code = context.getCode(); |
| 15 | + const tmpFile = GrammarUtils.createTempFileWithCode(code, '.dart'); |
| 16 | + return [tmpFile]; |
14 | 17 | },
|
15 | 18 | },
|
16 |
| - Dart: { |
17 |
| - 'Selection Based': { |
18 |
| - command: 'dart', |
19 |
| - args: (context) => { |
20 |
| - const code = context.getCode(); |
21 |
| - const tmpFile = GrammarUtils.createTempFileWithCode(code, '.dart'); |
22 |
| - return [tmpFile]; |
23 |
| - }, |
24 |
| - }, |
25 |
| - 'File Based': { |
26 |
| - command: 'dart', |
27 |
| - args: ({ filepath }) => [filepath], |
28 |
| - }, |
| 19 | + 'File Based': { |
| 20 | + command: 'dart', |
| 21 | + args: ({ filepath }) => [filepath], |
29 | 22 | },
|
30 |
| - JavaScript: { |
31 |
| - 'Selection Based': { |
32 |
| - command: 'babel-node', |
33 |
| - args: context => ['-e', context.getCode()], |
34 |
| - }, |
35 |
| - 'File Based': { |
36 |
| - command: 'babel-node', |
37 |
| - args: ({ filepath }) => [filepath], |
| 23 | +}; |
| 24 | +exports.JavaScript = { |
| 25 | + 'Selection Based': { |
| 26 | + command: 'bash', |
| 27 | + args: (context) => { |
| 28 | + const code = context.getCode(); |
| 29 | + const filepath = GrammarUtils.createTempFileWithCode(code, '.js'); |
| 30 | + return args({ filepath }); |
38 | 31 | },
|
39 | 32 | },
|
40 |
| - 'JavaScript for Automation (JXA)': { |
41 |
| - 'Selection Based': { |
42 |
| - command: 'osascript', |
43 |
| - args: context => ['-l', 'JavaScript', '-e', context.getCode()], |
44 |
| - }, |
45 |
| - 'File Based': { |
46 |
| - command: 'osascript', |
47 |
| - args: ({ filepath }) => ['-l', 'JavaScript', filepath], |
48 |
| - }, |
| 33 | + 'File Based': { command: 'bash', args }, |
| 34 | +}; |
| 35 | +exports['Babel ES6 JavaScript'] = exports.JavaScript; |
| 36 | +exports['JavaScript with JSX'] = exports.JavaScript; |
| 37 | + |
| 38 | +exports['JavaScript for Automation (JXA)'] = { |
| 39 | + 'Selection Based': { |
| 40 | + command: 'osascript', |
| 41 | + args: context => ['-l', 'JavaScript', '-e', context.getCode()], |
49 | 42 | },
|
50 |
| - 'JavaScript with JSX': { |
51 |
| - 'Selection Based': { |
52 |
| - command: 'babel-node', |
53 |
| - args: context => ['-e', context.getCode()], |
54 |
| - }, |
55 |
| - 'File Based': { |
56 |
| - command: 'babel-node', |
57 |
| - args: ({ filepath }) => [filepath], |
58 |
| - }, |
| 43 | + 'File Based': { |
| 44 | + command: 'osascript', |
| 45 | + args: ({ filepath }) => ['-l', 'JavaScript', filepath], |
59 | 46 | },
|
60 |
| - TypeScript: { |
61 |
| - 'Selection Based': { |
62 |
| - command: 'ts-node', |
63 |
| - args: context => ['-e', context.getCode()], |
64 |
| - }, |
65 |
| - 'File Based': { |
66 |
| - command: 'ts-node', |
67 |
| - args: ({ filepath }) => [filepath], |
68 |
| - }, |
| 47 | +}; |
| 48 | +exports.TypeScript = { |
| 49 | + 'Selection Based': { |
| 50 | + command: 'ts-node', |
| 51 | + args: context => ['-e', context.getCode()], |
| 52 | + }, |
| 53 | + 'File Based': { |
| 54 | + command: 'ts-node', |
| 55 | + args: ({ filepath }) => [filepath], |
69 | 56 | },
|
70 | 57 | };
|
0 commit comments