Skip to content

Commit

Permalink
move to XO (closes #397)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Sep 11, 2018
1 parent f5ecd25 commit ef3ec0a
Show file tree
Hide file tree
Showing 13 changed files with 766 additions and 613 deletions.
23 changes: 12 additions & 11 deletions examples/node/app.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
const http = require('http');

var debug = require('../../')('http')
, http = require('http')
, name = 'My App';
const debug = require('../..')('http');

// fake app
const name = 'My App';

// Fake app

debug('booting %o', name);

http.createServer(function(req, res){
debug(req.method + ' ' + req.url);
res.end('hello\n');
}).listen(3000, function(){
debug('listening');
http.createServer((req, res) => {
debug(req.method + ' ' + req.url);
res.end('hello\n');
}).listen(3000, () => {
debug('listening');
});

// fake worker of some kind

// Fake worker of some kind
// eslint-disable-next-line import/no-unassigned-import
require('./worker');
10 changes: 5 additions & 5 deletions examples/node/colors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var debug = require('../../')
const debug = require('../..');

debug.enable('*')
debug.enable('*');

for (var i=0; i < debug.colors.length; i++) {
const d = debug('example:' + i);
d('The color is %o', d.color);
for (let i = 0; i < debug.colors.length; i++) {
const d = debug('example:' + i);
d('The color is %o', d.color);
}
15 changes: 8 additions & 7 deletions examples/node/stdout.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
var debug = require('../../');
var error = debug('app:error');
const debug = require('../..');

// by default stderr is used
const error = debug('app:error');

// By default stderr is used
error('goes to stderr!');

var log = debug('app:log');
// set this namespace to log via console.log
log.log = console.log.bind(console); // don't forget to bind to console!
const log = debug('app:log');
// Set this namespace to log via console.log
log.log = console.log.bind(console); // Don't forget to bind to console!
log('goes to stdout');
error('still goes to stderr!');

// set all output to go via console.info
// Set all output to go via console.info
// overrides all per-namespace log settings
debug.log = console.info.bind(console);
error('now goes to stdout via console.info');
Expand Down
14 changes: 7 additions & 7 deletions examples/node/wildcards.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

var debug = {
foo: require('../../')('test:foo'),
bar: require('../../')('test:bar'),
baz: require('../../')('test:baz')
const debug = {
foo: require('../..')('test:foo'),
bar: require('../..')('test:bar'),
baz: require('../..')('test:baz')
};

debug.foo('foo')
debug.bar('bar')
debug.baz('baz')
debug.foo('foo');
debug.bar('bar');
debug.baz('baz');
17 changes: 9 additions & 8 deletions examples/node/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
// DEBUG=worker:a node example/worker
// DEBUG=worker:b node example/worker

var a = require('../../')('worker:a')
, b = require('../../')('worker:b');
const a = require('../..')('worker:a');

const b = require('../..')('worker:b');

function work() {
a('doing lots of uninteresting work');
setTimeout(work, Math.random() * 1000);
a('doing lots of uninteresting work');
setTimeout(work, Math.random() * 1000);
}

work();

function workb() {
b('doing some work');
setTimeout(workb, Math.random() * 2000);
b('doing some work');
setTimeout(workb, Math.random() * 2000);
}

workb();

setTimeout(function(){
b(new Error('fail'));
setTimeout(() => {
b(new Error('fail'));
}, 5000);
124 changes: 57 additions & 67 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,60 @@
// Karma configuration
// Generated on Fri Dec 16 2016 13:09:51 GMT+0000 (UTC)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai', 'sinon'],


// list of files / patterns to load in the browser
files: [
'dist/debug.js',
'test/*spec.js'
],


// list of files to exclude
exclude: [
'src/node.js'
],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
module.exports = function (config) {
config.set({

// Base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// Frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai', 'sinon'],

// List of files / patterns to load in the browser
files: [
'dist/debug.js',
'test/*spec.js'
],

// List of files to exclude
exclude: [
'src/node.js'
],

// Preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},

// Test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],

// Web server port
port: 9876,

// Enable / disable colors in the output (reporters and logs)
colors: true,

// Level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// Enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// Start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"url": "git://github.com/visionmedia/debug.git"
},
"description": "small debugging utility",
"scripts": {
"test": "xo && mocha"
},
"keywords": [
"debug",
"log",
Expand Down
Loading

0 comments on commit ef3ec0a

Please sign in to comment.