Skip to content

Commit ba8a424

Browse files
committed
move to XO (closes #397)
1 parent 2d2509e commit ba8a424

13 files changed

+766
-613
lines changed

examples/node/app.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
const http = require('http');
12

2-
var debug = require('../../')('http')
3-
, http = require('http')
4-
, name = 'My App';
3+
const debug = require('../..')('http');
54

6-
// fake app
5+
const name = 'My App';
6+
7+
// Fake app
78

89
debug('booting %o', name);
910

10-
http.createServer(function(req, res){
11-
debug(req.method + ' ' + req.url);
12-
res.end('hello\n');
13-
}).listen(3000, function(){
14-
debug('listening');
11+
http.createServer((req, res) => {
12+
debug(req.method + ' ' + req.url);
13+
res.end('hello\n');
14+
}).listen(3000, () => {
15+
debug('listening');
1516
});
1617

17-
// fake worker of some kind
18-
18+
// Fake worker of some kind
19+
// eslint-disable-next-line import/no-unassigned-import
1920
require('./worker');

examples/node/colors.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
var debug = require('../../')
1+
const debug = require('../..');
22

3-
debug.enable('*')
3+
debug.enable('*');
44

5-
for (var i=0; i < debug.colors.length; i++) {
6-
const d = debug('example:' + i);
7-
d('The color is %o', d.color);
5+
for (let i = 0; i < debug.colors.length; i++) {
6+
const d = debug('example:' + i);
7+
d('The color is %o', d.color);
88
}

examples/node/stdout.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
var debug = require('../../');
2-
var error = debug('app:error');
1+
const debug = require('../..');
32

4-
// by default stderr is used
3+
const error = debug('app:error');
4+
5+
// By default stderr is used
56
error('goes to stderr!');
67

7-
var log = debug('app:log');
8-
// set this namespace to log via console.log
9-
log.log = console.log.bind(console); // don't forget to bind to console!
8+
const log = debug('app:log');
9+
// Set this namespace to log via console.log
10+
log.log = console.log.bind(console); // Don't forget to bind to console!
1011
log('goes to stdout');
1112
error('still goes to stderr!');
1213

13-
// set all output to go via console.info
14+
// Set all output to go via console.info
1415
// overrides all per-namespace log settings
1516
debug.log = console.info.bind(console);
1617
error('now goes to stdout via console.info');

examples/node/wildcards.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
var debug = {
3-
foo: require('../../')('test:foo'),
4-
bar: require('../../')('test:bar'),
5-
baz: require('../../')('test:baz')
2+
const debug = {
3+
foo: require('../..')('test:foo'),
4+
bar: require('../..')('test:bar'),
5+
baz: require('../..')('test:baz')
66
};
77

8-
debug.foo('foo')
9-
debug.bar('bar')
10-
debug.baz('baz')
8+
debug.foo('foo');
9+
debug.bar('bar');
10+
debug.baz('baz');

examples/node/worker.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
// DEBUG=worker:a node example/worker
55
// DEBUG=worker:b node example/worker
66

7-
var a = require('../../')('worker:a')
8-
, b = require('../../')('worker:b');
7+
const a = require('../..')('worker:a');
8+
9+
const b = require('../..')('worker:b');
910

1011
function work() {
11-
a('doing lots of uninteresting work');
12-
setTimeout(work, Math.random() * 1000);
12+
a('doing lots of uninteresting work');
13+
setTimeout(work, Math.random() * 1000);
1314
}
1415

1516
work();
1617

1718
function workb() {
18-
b('doing some work');
19-
setTimeout(workb, Math.random() * 2000);
19+
b('doing some work');
20+
setTimeout(workb, Math.random() * 2000);
2021
}
2122

2223
workb();
2324

24-
setTimeout(function(){
25-
b(new Error('fail'));
25+
setTimeout(() => {
26+
b(new Error('fail'));
2627
}, 5000);

karma.conf.js

+57-67
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,60 @@
11
// Karma configuration
22
// Generated on Fri Dec 16 2016 13:09:51 GMT+0000 (UTC)
33

4-
module.exports = function(config) {
5-
config.set({
6-
7-
// base path that will be used to resolve all patterns (eg. files, exclude)
8-
basePath: '',
9-
10-
11-
// frameworks to use
12-
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13-
frameworks: ['mocha', 'chai', 'sinon'],
14-
15-
16-
// list of files / patterns to load in the browser
17-
files: [
18-
'dist/debug.js',
19-
'test/*spec.js'
20-
],
21-
22-
23-
// list of files to exclude
24-
exclude: [
25-
'src/node.js'
26-
],
27-
28-
29-
// preprocess matching files before serving them to the browser
30-
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
31-
preprocessors: {
32-
},
33-
34-
// test results reporter to use
35-
// possible values: 'dots', 'progress'
36-
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
37-
reporters: ['progress'],
38-
39-
40-
// web server port
41-
port: 9876,
42-
43-
44-
// enable / disable colors in the output (reporters and logs)
45-
colors: true,
46-
47-
48-
// level of logging
49-
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
50-
logLevel: config.LOG_INFO,
51-
52-
53-
// enable / disable watching file and executing tests whenever any file changes
54-
autoWatch: true,
55-
56-
57-
// start these browsers
58-
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
59-
browsers: ['PhantomJS'],
60-
61-
62-
// Continuous Integration mode
63-
// if true, Karma captures browsers, runs the tests and exits
64-
singleRun: false,
65-
66-
// Concurrency level
67-
// how many browser should be started simultaneous
68-
concurrency: Infinity
69-
})
70-
}
4+
module.exports = function (config) {
5+
config.set({
6+
7+
// Base path that will be used to resolve all patterns (eg. files, exclude)
8+
basePath: '',
9+
10+
// Frameworks to use
11+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
12+
frameworks: ['mocha', 'chai', 'sinon'],
13+
14+
// List of files / patterns to load in the browser
15+
files: [
16+
'dist/debug.js',
17+
'test/*spec.js'
18+
],
19+
20+
// List of files to exclude
21+
exclude: [
22+
'src/node.js'
23+
],
24+
25+
// Preprocess matching files before serving them to the browser
26+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
27+
preprocessors: {
28+
},
29+
30+
// Test results reporter to use
31+
// possible values: 'dots', 'progress'
32+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
33+
reporters: ['progress'],
34+
35+
// Web server port
36+
port: 9876,
37+
38+
// Enable / disable colors in the output (reporters and logs)
39+
colors: true,
40+
41+
// Level of logging
42+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
43+
logLevel: config.LOG_INFO,
44+
45+
// Enable / disable watching file and executing tests whenever any file changes
46+
autoWatch: true,
47+
48+
// Start these browsers
49+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
50+
browsers: ['PhantomJS'],
51+
52+
// Continuous Integration mode
53+
// if true, Karma captures browsers, runs the tests and exits
54+
singleRun: false,
55+
56+
// Concurrency level
57+
// how many browser should be started simultaneous
58+
concurrency: Infinity
59+
});
60+
};

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"url": "git://github.com/visionmedia/debug.git"
77
},
88
"description": "small debugging utility",
9+
"scripts": {
10+
"test": "xo && mocha"
11+
},
912
"keywords": [
1013
"debug",
1114
"log",

0 commit comments

Comments
 (0)