smipper 7.0.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +57 -46
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,12 +3,64 @@
|
|
|
3
3
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const got = require("got");
|
|
6
|
+
const path = require("path");
|
|
6
7
|
const sourceMap = require("source-map");
|
|
7
8
|
const url = require("url");
|
|
9
|
+
|
|
8
10
|
let verbose = false;
|
|
9
11
|
let stack;
|
|
10
12
|
let json = false;
|
|
11
13
|
let retries = 3;
|
|
14
|
+
let jsc = 0;
|
|
15
|
+
|
|
16
|
+
let hasInput = false;
|
|
17
|
+
for (let i=2; i<process.argv.length; ++i) {
|
|
18
|
+
try {
|
|
19
|
+
const arg = process.argv[i];
|
|
20
|
+
if (verbose)
|
|
21
|
+
console.error("got arg", arg);
|
|
22
|
+
if (arg === "-f" || arg === "--file") {
|
|
23
|
+
stack = fs.readFileSync(process.argv[++i]).toString();
|
|
24
|
+
} else if ( arg.startsWith("-f") === 0) {
|
|
25
|
+
stack = fs.readFileSync(arg.substr(2)).toString();
|
|
26
|
+
} else if (arg.startsWith("--file=") === 0) {
|
|
27
|
+
stack = fs.readFileSync(arg.substr(7)).toString();
|
|
28
|
+
} else if (arg === "--verbose" || arg === "-v") {
|
|
29
|
+
verbose = true;
|
|
30
|
+
} else if (arg === "--version") {
|
|
31
|
+
console.log(JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8")).version);
|
|
32
|
+
process.exit(0);
|
|
33
|
+
} else if (arg === "--json") {
|
|
34
|
+
json = true;
|
|
35
|
+
} else if (arg === "--jsc") { // jsc has the wrong column for some reason
|
|
36
|
+
jsc = 1;
|
|
37
|
+
} else if (arg.startsWith("--retries")) {
|
|
38
|
+
retries = parseInt(arg.substr(9));
|
|
39
|
+
if (isNaN(retries) || retries < 0) {
|
|
40
|
+
console.error("smipper [stack|-h|--help|-v|--verbose|--version|--retries=<number>|--jsc|--json|-f=@FILE@|-");
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
} else if (arg === "-h" || arg === "--help") {
|
|
44
|
+
console.error("smipper [stack|-h|--help|-v|--verbose|--version|--retries=<number>|--jsc|--json|-f=@FILE@|-");
|
|
45
|
+
process.exit(0);
|
|
46
|
+
} else if (arg === "-") {
|
|
47
|
+
// stdin
|
|
48
|
+
} else {
|
|
49
|
+
stack = arg;
|
|
50
|
+
}
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.error("Error: " + err.toString());
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!stack) {
|
|
58
|
+
stack = fs.readFileSync("/dev/stdin").toString();
|
|
59
|
+
if (!stack) {
|
|
60
|
+
console.error("Nothing to do");
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
12
64
|
|
|
13
65
|
function load(path)
|
|
14
66
|
{
|
|
@@ -21,6 +73,10 @@ function load(path)
|
|
|
21
73
|
}
|
|
22
74
|
return;
|
|
23
75
|
}
|
|
76
|
+
if (!path.startsWith("http://") && !path.startsWith("https://")) {
|
|
77
|
+
reject(new Error("Not a url"));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
24
80
|
let retryIndex = 0;
|
|
25
81
|
async function get()
|
|
26
82
|
{
|
|
@@ -86,50 +142,6 @@ function loadUri(path) {
|
|
|
86
142
|
});
|
|
87
143
|
}
|
|
88
144
|
|
|
89
|
-
let hasInput = false;
|
|
90
|
-
for (let i=2; i<process.argv.length; ++i) {
|
|
91
|
-
try {
|
|
92
|
-
const arg = process.argv[i];
|
|
93
|
-
if (verbose)
|
|
94
|
-
console.error("got arg", arg);
|
|
95
|
-
if (arg === "-f" || arg === "--file") {
|
|
96
|
-
stack = fs.readFileSync(process.argv[++i]).toString();
|
|
97
|
-
} else if ( arg.startsWith("-f") === 0) {
|
|
98
|
-
stack = fs.readFileSync(arg.substr(2)).toString();
|
|
99
|
-
} else if (arg.startsWith("--file=") === 0) {
|
|
100
|
-
stack = fs.readFileSync(arg.substr(7)).toString();
|
|
101
|
-
} else if (arg === "--verbose" || arg === "-v") {
|
|
102
|
-
verbose = true;
|
|
103
|
-
} else if (arg === "--json") {
|
|
104
|
-
json = true;
|
|
105
|
-
} else if (arg.startsWith("--retries")) {
|
|
106
|
-
retries = parseInt(arg.substr(9));
|
|
107
|
-
if (isNaN(retries) || retries < 0) {
|
|
108
|
-
console.error("smipper [stack|-h|--help|-v|--verbose|--retries=<number>|--json|-f=@FILE@|-");
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
|
-
} else if (arg === "-h" || arg === "--help") {
|
|
112
|
-
console.error("smipper [stack|-h|--help|-v|--verbose|--retries=<number>|--json|-f=@FILE@|-");
|
|
113
|
-
process.exit(0);
|
|
114
|
-
} else if (arg === "-") {
|
|
115
|
-
// stdin
|
|
116
|
-
} else {
|
|
117
|
-
stack = arg;
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
console.error("Error: " + err.toString());
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (!stack) {
|
|
126
|
-
stack = fs.readFileSync("/dev/stdin").toString();
|
|
127
|
-
if (!stack) {
|
|
128
|
-
console.error("Nothing to do");
|
|
129
|
-
process.exit(0);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
145
|
function processFrame(functionName, url, line, column)
|
|
134
146
|
{
|
|
135
147
|
if (verbose)
|
|
@@ -149,8 +161,7 @@ function processFrame(functionName, url, line, column)
|
|
|
149
161
|
|
|
150
162
|
// it appears that we're supposed to reduce the column
|
|
151
163
|
// number by 1 when we get this from jsc
|
|
152
|
-
|
|
153
|
-
const pos = smap.originalPositionFor({ line, column });
|
|
164
|
+
const pos = smap.originalPositionFor({ line, column: column - jsc });
|
|
154
165
|
if (!pos.source) {
|
|
155
166
|
if (verbose)
|
|
156
167
|
console.error("nothing here", pos);
|