-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
36 lines (32 loc) · 1.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
var program = require('commander')
var fs = require('fs')
var sourceMap = require("source-map");
program.version('1.0.0')
.option('-f --file [file]','source map file')
.option('-l --line [row]','error message row line')
.option('-c --column [column]','error message colomn number')
.parse(process.argv)
if(!program.file || !program.column || !program.line){
console.error('please input map file name or error line error column')
process.exit(1)
}
fs.stat(program.file,(err, stats)=>{
if(err){
console.error('source map file is not exist, please retry it')
process.exit(1)
}else{
if( isNaN(parseInt(program.line,10)) || isNaN(parseInt(program.column,10))){
console.log('you error column or error line is not number')
process.exit(1)
}else{
fs.readFile(program.file,(err,data)=>{
var smc = new sourceMap.SourceMapConsumer(data.toString());
console.log(smc.originalPositionFor({
line: parseInt(program.line,10),
column: parseInt(program.column,10),
}));
})
}
}
})