Skip to content

Commit d1b0ff2

Browse files
authored
Improve support for modern JavaScript (#1427)
Also utilises _babel-preset-env_ to automatically target the current version of Node being run by Atom.
1 parent a7cdc38 commit d1b0ff2

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

examples/modern.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {exec} from 'child_process'
2+
3+
const timeout = s => new Promise(resolve => setTimeout(resolve, s * 1000)) // ms
4+
5+
const sleep = async(s, message) => {
6+
console.log("Awaiting Promise…") // This selected line should run.
7+
await timeout(s)
8+
return console.log(message)
9+
}
10+
11+
sleep(1, "Done.")

lib/grammars.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,18 +431,18 @@ module.exports =
431431

432432
JavaScript:
433433
"Selection Based":
434-
command: "node"
434+
command: "babel-node"
435435
args: (context) -> ['-e', context.getCode()]
436436
"File Based":
437-
command: "node"
437+
command: "babel-node"
438438
args: (context) -> [context.filepath]
439439

440440
'JavaScript with JSX':
441441
"Selection Based":
442-
command: "node"
442+
command: "babel-node"
443443
args: (context) -> ['-e', context.getCode()]
444444
"File Based":
445-
command: "node"
445+
command: "babel-node"
446446
args: (context) -> [context.filepath]
447447

448448
"JavaScript for Automation (JXA)":

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@
340340
"uuid": "^3.0.1"
341341
},
342342
"optionalDependencies": {
343+
"babel-cli": "^6.26.0",
343344
"coffeescript": "^2"
344345
},
345346
"devDependencies": {

0 commit comments

Comments
 (0)