Skip to content

Commit 9e74d21

Browse files
committed
adding eslint and making fixes
1 parent 78fbcf1 commit 9e74d21

File tree

8 files changed

+45
-16
lines changed

8 files changed

+45
-16
lines changed

.eslintrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": [
3+
"@dominicbarnes",
4+
"@dominicbarnes/node"
5+
],
6+
"rules": {
7+
"global-require": 0,
8+
"no-console": 0,
9+
"no-process-exit": 0
10+
}
11+
}

bin/_duo-tester

+5-3
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ if (!program.args.length) program.help();
6161
* @param {Function} runner
6262
*/
6363

64-
function run(runner, files, options) {
65-
var runner = require('../lib/' + runner);
64+
function run(id, files, options) {
65+
var runner = require('../lib/' + id);
6666
var root = options.parent.root;
6767
var entries = getEntries(files, root);
6868
var plugins = getPlugins(options.parent.use, root);
69+
var port = options.parent.port;
6970

7071
runner(entries, {
7172
root: root,
72-
plugins: plugins
73+
plugins: plugins,
74+
port: port
7375
});
7476
}
7577

lib/browser.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ var serve = require('duo-serve');
1313
*/
1414

1515
module.exports = function (entries, options) {
16-
var url = 'http://localhost:' + options.port + '/';
17-
1816
var server = serve(options.root)
1917
.entry(entries)
2018
.html(html)
@@ -32,7 +30,7 @@ module.exports = function (entries, options) {
3230

3331
server.listen(options.port, function () {
3432
console.log();
35-
console.log(' duo-tester running at %s', url);
33+
console.log(' duo-tester running at http://localhost:%d/', options.port);
3634
console.log();
3735
});
3836
};

lib/phantom.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ var spawn = require('win-spawn');
1616
*/
1717

1818
module.exports = function (entries, options) {
19-
var url = 'http://localhost:' + options.port + '/';
20-
2119
var server = serve(options.root)
2220
.entry(entries)
2321
.favicon(false)
@@ -35,13 +33,12 @@ module.exports = function (entries, options) {
3533
res.sendFile(path.resolve(mocha, '../mocha.js'));
3634
});
3735

38-
server.listen(options.port, start);
39-
};
40-
41-
function start() {
42-
var proc = spawn(phantomjs.path, [ script, url ], { stdio: 'inherit' });
36+
server.listen(options.port, function () {
37+
var url = 'http://localhost:' + options.port + '/';
38+
var proc = spawn(phantomjs.path, [ script, url ], { stdio: 'inherit' });
4339

44-
proc.on('exit', function (code) {
45-
process.exit(code);
40+
proc.on('exit', function (code) {
41+
process.exit(code);
42+
});
4643
});
47-
}
44+
};

package.json

+8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212
"mocha-phantomjs": "^3.5.3",
1313
"win-spawn": "^2.0.0"
1414
},
15+
"devDependencies": {
16+
"@dominicbarnes/eslint-config": "*",
17+
"@dominicbarnes/eslint-config-node": "*",
18+
"@dominicbarnes/eslint-config-test": "*",
19+
"eslint": "^1.10.3",
20+
"eslint-plugin-require-path-exists": "^1.0.25"
21+
},
1522
"scripts": {
23+
"lint": "eslint bin lib",
1624
"hooks": "cp scripts/hooks/* .git/hooks/"
1725
}
1826
}

test/.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@dominicbarnes/test"
3+
}

test/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
describe('smoke test', function () {
3+
it('should not explode', function () {
4+
assert.equal(2 + 2, 4);
5+
});
6+
});

test/sum.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
module.exports = function (a, b) {
3+
return a + b;
4+
};

0 commit comments

Comments
 (0)