Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre release goodies #601

Merged
merged 9 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": "58",
"ie": "8"
}
}
]
]
}
37 changes: 37 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
root = true

[*]
indent_style = tab
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{*.json,*.json.example,*.gyp,*.yml,*.yaml}]
indent_style = space
indent_size = 2

[{*.py,*.asm}]
indent_style = space

[*.py]
indent_size = 4

[*.asm]
indent_size = 8

[*.md]
trim_trailing_whitespace = false

# Ideal settings - some plugins might support these.
[*.js]
quote_type = single

[{*.c,*.cc,*.h,*.hh,*.cpp,*.hpp,*.m,*.mm,*.mpp,*.js,*.java,*.go,*.rs,*.php,*.ng,*.jsx,*.ts,*.d,*.cs,*.swift}]
curly_bracket_next_line = false
spaces_around_operators = true
spaces_around_brackets = outside
# close enough to 1TB
indent_brace_style = K&R
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.DS_Store
node_modules
node_modules/
*.sock
build
/build/
npm-debug.log
dist
coverage
yarn-error.log
/dist/
/coverage/

# lockfiles
yarn.lock
Expand Down
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ node_js:
- "10"

install:
- make install
- npm install

script:
- make lint
- make test

matrix:
include:
- node_js: '8'
env: BROWSER=1
- make all
45 changes: 17 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,38 @@ PATH := node_modules/.bin:$(PATH)
SHELL := /bin/bash

# applications
NODE ?= $(shell which node)
YARN ?= $(shell which yarn)
PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm))
BROWSERIFY ?= $(NODE) $(BIN)/browserify
BROWSERIFY ?= $(BIN)/browserify

install: node_modules
all: lint test

browser: dist/debug.js
browser: dist/debug.js dist/test.js

node_modules: package.json
@NODE_ENV= $(PKG) install
@touch node_modules
dist/debug.js: src/*.js
@mkdir -p dist
@$(BROWSERIFY) --standalone debug . > [email protected]
@babel [email protected] > $@
@rm [email protected]

dist/debug.js: src/*.js node_modules
dist/test.js: test.js
@mkdir -p dist
@$(BROWSERIFY) \
--standalone debug \
. > dist/debug.js
@cp $< [email protected]
@babel [email protected] > $@
@rm [email protected].js

lint:
@eslint *.js src/*.js
@xo

test-node:
@istanbul cover node_modules/mocha/bin/_mocha -- test/**.js
@istanbul cover node_modules/mocha/bin/_mocha -- test.js
@cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

test-browser:
@$(MAKE) browser
@karma start --single-run

test-all:
@concurrently \
"make test-node" \
"make test-browser"

test:
@if [ "x$(BROWSER)" = "x" ]; then \
$(MAKE) test-node; \
else \
$(MAKE) test-browser; \
fi
test: test-node test-browser

clean:
rimraf dist coverage
rm -rf dist coverage

.PHONY: browser install clean lint test test-all test-node test-browser
.PHONY: all browser install clean lint test test-node test-browser
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);
Loading