Skip to content

Instantly share code, notes, and snippets.

@deptno
Created October 30, 2018 04:00
Show Gist options
  • Save deptno/dd5de59a454602a770b2bd5c5199c4a5 to your computer and use it in GitHub Desktop.
Save deptno/dd5de59a454602a770b2bd5c5199c4a5 to your computer and use it in GitHub Desktop.
extract line number sample
const stack = new Error().stack!.split('\n').slice(3)[0]
const regexp = /\((\S+)\)/
const match = stack.match(regexp)![1]
const line = `${path.basename(path.dirname(match))}/${path.basename(match)}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment