Skip to content

Commit

Permalink
improving Windows compatibility (SyntaxErrors parsing)
Browse files Browse the repository at this point in the history
  • Loading branch information
xpl committed Dec 29, 2017
1 parent 9a96b15 commit 2c19bdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 7 additions & 5 deletions stacktracey.js
Expand Up @@ -52,13 +52,15 @@ class StackTracey extends Array {

if (isParseableSyntaxError) {

const rawLines = module.require ('util').inspect (originalInput).split ('\n')
, fileLine = rawLines[0].match (/^([^:]+):(.+)/)
const rawLines = module.require ('util').inspect (originalInput).split ('\n')
, fileLine = rawLines[0].split (':')
, line = fileLine.pop ()
, file = fileLine.join (':')

if (fileLine) {
if (file) {
input.unshift ({
file: nixSlashes (fileLine[1]),
line: fileLine[2],
file: nixSlashes (file),
line: line,
column: (rawLines[2] || '').indexOf ('^') + 1,
sourceLine: rawLines[1],
callee: '(syntax error)',
Expand Down
4 changes: 1 addition & 3 deletions test.js
Expand Up @@ -196,13 +196,11 @@ describe ('StackTracey', () => {
const nodeVersion = Number (process.version.match(/^v(\d+\.\d+)/)[1])
if (nodeVersion >= 5) {

it.only ('recognizes SyntaxErrors', () => {
it ('recognizes SyntaxErrors', () => {

try { require ('./test_files/syntax_error.js') }
catch (e) {

console.log (require ('util').inspect (e), '\n')

const stack = new StackTracey (e).clean

console.log ('')
Expand Down

0 comments on commit 2c19bdc

Please sign in to comment.