Skip to content

Commit

Permalink
feat: make parser support ES9 (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
rndmerle authored and bahmutov committed Jun 5, 2019
1 parent edae703 commit 27f9b96
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/task-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ const isItSkip = node => {

const getItsName = node => node.arguments[0].value

const parseAndEdit = (source, callback, { module = false } = {}) =>
falafel(
source,
{ sourceType: module ? "module" : "script", ecmaVersion: 9 },
callback
)

/**
* Given a spec filename and name of a test, sets "it.only" for give list of tests.
*/
Expand Down Expand Up @@ -97,10 +104,10 @@ export const onlyTests = (specFilename, leaveTests) => {
}
let output;
try {
output = falafel(source, skipAllTests)
output = parseAndEdit(source, skipAllTests)
} catch(err) {
if (err.stack.includes("'import' and 'export' may appear only with 'sourceType: module'")) {
output = falafel(source, { sourceType: "module" }, skipAllTests)
output = parseAndEdit(source, skipAllTests, { module: true })
}
}
// console.log(output)
Expand Down Expand Up @@ -157,10 +164,10 @@ export const skipTests = (specFilename, skipTests) => {
}
let output;
try {
output = falafel(source, skipAllTests)
output = parseAndEdit(source, skipAllTests)
} catch(err) {
if (err.stack.includes("'import' and 'export' may appear only with 'sourceType: module'")) {
output = falafel(source, { sourceType: "module" }, skipAllTests)
output = parseAndEdit(source, skipAllTests, { module: true })
}
}
// console.log(output)
Expand Down Expand Up @@ -202,10 +209,10 @@ export const runAllTests = specFilename => {
}
let output;
try {
output = falafel(source, enableAllTests)
output = parseAndEdit(source, enableAllTests)
} catch(err) {
if (err.stack.includes("'import' and 'export' may appear only with 'sourceType: module'")) {
output = falafel(source, { sourceType: "module" }, enableAllTests)
output = parseAndEdit(source, enableAllTests, { module: true })
}
}
// console.log(output)
Expand Down

0 comments on commit 27f9b96

Please sign in to comment.