|
1 | | -var fs = require('fs'); |
2 | | -var path = require('path'); |
3 | | -var spawn = require('child_process').spawn; |
| 1 | +var fs = require('fs') |
| 2 | +var path = require('path') |
| 3 | +var spawn = require('child_process').spawn |
4 | 4 |
|
5 | 5 | var searchPaths = [ |
6 | 6 | path.resolve(__dirname, '..', 'build', 'Release'), |
7 | 7 | path.resolve(__dirname, '..', 'build', 'Debug'), |
8 | | - path.resolve(__dirname, '..', 'bin'), |
9 | | -]; |
10 | | -function searchCommand(command) { |
11 | | - if (process.platform == 'win32') { |
| 8 | + path.resolve(__dirname, '..', 'bin') |
| 9 | +] |
| 10 | + |
| 11 | +function searchCommand (command) { |
| 12 | + var binaryPath = null |
| 13 | + if (process.platform === 'win32') { |
12 | 14 | command += '.exe' |
13 | | - var binaryPath = path.join(__dirname, '..', 'deps', 'breakpad', command) |
14 | | - if (fs.existsSync(binaryPath)) |
15 | | - return binaryPath; |
| 15 | + binaryPath = path.join(__dirname, '..', 'deps', 'breakpad', command) |
| 16 | + if (fs.existsSync(binaryPath)) { |
| 17 | + return binaryPath |
| 18 | + } |
16 | 19 | } else { |
17 | 20 | for (var i in searchPaths) { |
18 | | - var binaryPath = path.join(searchPaths[i], command); |
19 | | - if (fs.existsSync(binaryPath)) |
20 | | - return binaryPath; |
| 21 | + binaryPath = path.join(searchPaths[i], command) |
| 22 | + if (fs.existsSync(binaryPath)) { |
| 23 | + return binaryPath |
| 24 | + } |
21 | 25 | } |
22 | 26 | } |
23 | 27 | } |
24 | 28 |
|
25 | | -function execute(command, args, callback) { |
26 | | - var stdout = new Buffer(0); |
27 | | - var stderr = new Buffer(0); |
28 | | - var child = spawn(command, args); |
29 | | - child.stdout.on('data', function(chunk) { |
30 | | - stdout = Buffer.concat([stdout, chunk]); |
31 | | - }); |
32 | | - child.stderr.on('data', function(chunk) { |
33 | | - stderr = Buffer.concat([stderr, chunk]); |
34 | | - }); |
35 | | - child.on('close', function(code) { |
36 | | - if (code != 0) |
37 | | - callback(stderr ? new Error(stderr.toString()) : new Error("Command `" + command + "` failed: " + code)); |
38 | | - else |
39 | | - callback(null, stdout); |
40 | | - }); |
| 29 | +function execute (command, args, callback) { |
| 30 | + var stdout = new Buffer(0) |
| 31 | + var stderr = new Buffer(0) |
| 32 | + var child = spawn(command, args) |
| 33 | + child.stdout.on('data', function (chunk) { |
| 34 | + stdout = Buffer.concat([stdout, chunk]) |
| 35 | + }) |
| 36 | + child.stderr.on('data', function (chunk) { |
| 37 | + stderr = Buffer.concat([stderr, chunk]) |
| 38 | + }) |
| 39 | + child.on('close', function (code) { |
| 40 | + if (code !== 0) { |
| 41 | + callback(stderr ? new Error(stderr.toString()) : new Error('Command `' + command + '` failed: ' + code)) |
| 42 | + } else { |
| 43 | + callback(null, stdout) |
| 44 | + } |
| 45 | + }) |
41 | 46 | } |
42 | 47 |
|
43 | | -var globalSymbolPaths = []; |
44 | | -module.exports.addSymbolPath = Array.prototype.push.bind(globalSymbolPaths); |
| 48 | +var globalSymbolPaths = [] |
| 49 | +module.exports.addSymbolPath = Array.prototype.push.bind(globalSymbolPaths) |
45 | 50 |
|
46 | | -module.exports.walkStack = function(minidump, symbolPaths, callback) { |
| 51 | +module.exports.walkStack = function (minidump, symbolPaths, callback) { |
47 | 52 | if (!callback) { |
48 | | - callback = symbolPaths; |
49 | | - symbolPaths = []; |
| 53 | + callback = symbolPaths |
| 54 | + symbolPaths = [] |
50 | 55 | } |
51 | 56 |
|
52 | | - var stackwalk = searchCommand('minidump_stackwalk'); |
| 57 | + var stackwalk = searchCommand('minidump_stackwalk') |
53 | 58 | if (!stackwalk) { |
54 | | - callback(new Error('Unable to find "minidump_stackwalk"')); |
55 | | - return; |
| 59 | + callback(new Error('Unable to find "minidump_stackwalk"')) |
| 60 | + return |
56 | 61 | } |
57 | 62 |
|
58 | | - args = [minidump].concat(symbolPaths, globalSymbolPaths) |
59 | | - execute(stackwalk, args, callback); |
| 63 | + var args = [minidump].concat(symbolPaths, globalSymbolPaths) |
| 64 | + execute(stackwalk, args, callback) |
60 | 65 | } |
61 | 66 |
|
62 | | -module.exports.dumpSymbol = function(binary, callback) { |
63 | | - var dumpsyms = searchCommand('dump_syms'); |
| 67 | +module.exports.dumpSymbol = function (binary, callback) { |
| 68 | + var dumpsyms = searchCommand('dump_syms') |
64 | 69 | if (!dumpsyms) { |
65 | | - callback(new Error('Unable to find "dump_syms"')); |
66 | | - return; |
| 70 | + callback(new Error('Unable to find "dump_syms"')) |
| 71 | + return |
67 | 72 | } |
68 | 73 |
|
69 | 74 | // Search for binary.dSYM on OS X. |
70 | | - dsymPath = binary + '.dSYM'; |
71 | | - if (process.platform == 'darwin' && fs.existsSync(dsymPath)) |
72 | | - binary = dsymPath; |
| 75 | + var dsymPath = binary + '.dSYM' |
| 76 | + if (process.platform === 'darwin' && fs.existsSync(dsymPath)) { |
| 77 | + binary = dsymPath |
| 78 | + } |
73 | 79 |
|
74 | 80 | execute(dumpsyms, ['-r', '-c', binary], callback) |
75 | 81 | } |
0 commit comments