Skip to content

Commit

Permalink
fix: Handle relative paths in parser config
Browse files Browse the repository at this point in the history
Closes #85
  • Loading branch information
NickTomlin committed Feb 10, 2018
1 parent 87c9313 commit 874a08e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/parsers/index.js
@@ -1,5 +1,5 @@
import cucumber from './cucumber'
import { extname } from 'path'
import { resolve, extname } from 'path'
import multi from './multi'
import standard from './standard'

Expand All @@ -14,12 +14,17 @@ function handleObject (parserObject) {
}

function handlePath (parserPath) {
// 'my-custom-parser' or './my-custom-parser'
try {
let customParserPath = require.resolve(parserPath)
return require(customParserPath)
} catch (e) {
throw new Error(`Invalid Custom Parser Path Specified: ${parserPath}`)
}
return require(parserPath)
} catch (e) {}

// /path/to/parser or ../path/to/parser
try {
return require(resolve(parserPath))
} catch (e) {}

throw new Error(`Invalid Custom Parser Path Specified: ${parserPath}`)
}

function handleFlakeParser (parserName) {
Expand Down

0 comments on commit 874a08e

Please sign in to comment.