stack-sites
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "stack-sites", | ||
"description": "Returns current stack as call sites", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
@@ -48,2 +48,5 @@ "bugs": "https://github.com/bahmutov/stack-sites/issues", | ||
}, | ||
"release": { | ||
"analyzeCommits": "simple-commit-message" | ||
}, | ||
"scripts": { | ||
@@ -67,8 +70,9 @@ "ban": "ban", | ||
"git-issues": "1.3.1", | ||
"license-checker": "8.0.3", | ||
"license-checker": "8.0.4", | ||
"mocha": "3.2.0", | ||
"nsp": "2.6.2", | ||
"pre-git": "3.12.0", | ||
"standard": "8.6.0", | ||
"semantic-release": "^6.3.2" | ||
"nsp": "2.6.3", | ||
"pre-git": "3.14.0", | ||
"semantic-release": "6.3.6", | ||
"simple-commit-message": "3.0.2", | ||
"standard": "8.6.0" | ||
}, | ||
@@ -75,0 +79,0 @@ "dependencies": { |
@@ -10,8 +10,9 @@ 'use strict' | ||
function isModule (line) { | ||
return line.includes('(/') | ||
return line.includes('(/') || | ||
line.includes(' (') // on Windows: at stackSites (c:\Users...) | ||
} | ||
function stackSites () { | ||
const e = new Error('stack-sites') | ||
return e.stack.split('\n') | ||
function stackSites (stack) { | ||
stack = stack || ((new Error('stack-sites').stack)) | ||
return stack.split('\n') | ||
.slice(1) // remove exception itself | ||
@@ -18,0 +19,0 @@ .filter(hasLineInfo) |
const la = require('lazy-ass') | ||
const is = require('check-more-types') | ||
// function isNotEmpty (s) { | ||
// return s | ||
// } | ||
function parseLinuxPath (parts) { | ||
la(parts.length === 3, 'invalid number of Linux path parts', parts) | ||
return { | ||
filename: parts[0], | ||
line: parts[1], | ||
column: parts[2] | ||
} | ||
} | ||
function parseWindowsPath (parts) { | ||
la(parts.length === 4, 'invalid number of Windows path parts', parts) | ||
return { | ||
filename: parts[0] + ':' + parts[1], | ||
line: parts[2], | ||
column: parts[3] | ||
} | ||
} | ||
// s is like (/src/index.js:4:13) | ||
// or (on Windows) (c:\Users\src\index.js:4:13) | ||
function parseAt (s, fullLine) { | ||
@@ -14,8 +29,10 @@ const parts = s.replace(/\(/, '') | ||
.split(':') | ||
la(parts.length === 3, 'invalid number of parts', s, 'full line', fullLine) | ||
return { | ||
filename: parts[0], | ||
line: parts[1], | ||
column: parts[2] | ||
la(parts.length > 2, 'invalid number of parts', s, 'full line', fullLine) | ||
if (parts.length === 3) { | ||
return parseLinuxPath(parts) | ||
} | ||
if (parts.length === 4) { | ||
return parseWindowsPath(parts) | ||
} | ||
la(false, 'Do not know how to parse parts', parts, 'from line', fullLine) | ||
} | ||
@@ -22,0 +39,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7188
72
11