UNPKG

369 BJavaScriptView Raw
1'use strict'
2
3const fpStackTracePattern = /at\s{1}(?:.*\.)?plugin\s{1}.*\n\s*(.*)/
4const fileNamePattern = /(\w*(\.\w*)*)\..*/
5
6module.exports = function extractPluginName (stack) {
7 const m = stack.match(fpStackTracePattern)
8
9 // get last section of path and match for filename
10 return m ? m[1].split(/[/\\]/).slice(-1)[0].match(fileNamePattern)[1] : 'anonymous'
11}