Skip to content

Commit 1a79e05

Browse files
authored
Merge pull request #21 from electron/standard
Lint with standard
2 parents d39d90f + a8ec555 commit 1a79e05

File tree

4 files changed

+62
-51
lines changed

4 files changed

+62
-51
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ npm install minidump
77
```
88

99
## Building
10-
* Clone the repository recursively
11-
* Run `npm install`
10+
11+
* `git clone --recurse-submodules https://github.com/electron/node-minidump`
12+
* `npm install`
1213

1314
## Docs
1415

lib/minidump.js

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,81 @@
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
44

55
var searchPaths = [
66
path.resolve(__dirname, '..', 'build', 'Release'),
77
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') {
1214
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+
}
1619
} else {
1720
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+
}
2125
}
2226
}
2327
}
2428

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+
})
4146
}
4247

43-
var globalSymbolPaths = [];
44-
module.exports.addSymbolPath = Array.prototype.push.bind(globalSymbolPaths);
48+
var globalSymbolPaths = []
49+
module.exports.addSymbolPath = Array.prototype.push.bind(globalSymbolPaths)
4550

46-
module.exports.walkStack = function(minidump, symbolPaths, callback) {
51+
module.exports.walkStack = function (minidump, symbolPaths, callback) {
4752
if (!callback) {
48-
callback = symbolPaths;
49-
symbolPaths = [];
53+
callback = symbolPaths
54+
symbolPaths = []
5055
}
5156

52-
var stackwalk = searchCommand('minidump_stackwalk');
57+
var stackwalk = searchCommand('minidump_stackwalk')
5358
if (!stackwalk) {
54-
callback(new Error('Unable to find "minidump_stackwalk"'));
55-
return;
59+
callback(new Error('Unable to find "minidump_stackwalk"'))
60+
return
5661
}
5762

58-
args = [minidump].concat(symbolPaths, globalSymbolPaths)
59-
execute(stackwalk, args, callback);
63+
var args = [minidump].concat(symbolPaths, globalSymbolPaths)
64+
execute(stackwalk, args, callback)
6065
}
6166

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')
6469
if (!dumpsyms) {
65-
callback(new Error('Unable to find "dump_syms"'));
66-
return;
70+
callback(new Error('Unable to find "dump_syms"'))
71+
return
6772
}
6873

6974
// 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+
}
7379

7480
execute(dumpsyms, ['-r', '-c', binary], callback)
7581
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
"url": "https://github.com/electron/node-minidump/issues"
1616
},
1717
"scripts": {
18-
"test": "mocha test"
18+
"test": "mocha test && standard"
1919
},
2020
"devDependencies": {
2121
"electron-download": "^3.0.1",
2222
"extract-zip": "^1.5.0",
2323
"mocha": "^3.1.2",
24+
"standard": "^8.4.0",
2425
"temp": "^0.8.3"
2526
}
2627
}

test/minidump-test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ var electronDownload = require('electron-download')
66
var extractZip = require('extract-zip')
77
var temp = require('temp').track()
88

9+
var describe = global.describe
10+
var it = global.it
11+
912
describe('minidump', function () {
1013
this.timeout(3 * 60 * 1000)
1114

@@ -105,7 +108,7 @@ var downloadElectron = function (callback) {
105108
} else {
106109
callback(null, path.join(electronPath, 'electron'))
107110
}
108-
})
111+
})
109112
})
110113
}
111114

@@ -123,6 +126,6 @@ var downloadElectronSymbols = function (platform, callback) {
123126
extractZip(zipPath, {dir: symbolsPath}, function (error) {
124127
if (error) return callback(error)
125128
callback(null, path.join(symbolsPath, 'electron.breakpad.syms'))
126-
})
129+
})
127130
})
128131
}

0 commit comments

Comments
 (0)