Skip to content

Commit

Permalink
remove build system (closes #652)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Dec 19, 2018
1 parent 0e94034 commit 6489766
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 88 deletions.
13 changes: 0 additions & 13 deletions .babelrc

This file was deleted.

41 changes: 16 additions & 25 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
// 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'],
frameworks: ['browserify', 'mocha'],

// List of files / patterns to load in the browser
files: [
'dist/debug.js',
'dist/test.js'
'src/browser.js',
'src/common.js',
'test.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
Expand All @@ -42,9 +26,6 @@ module.exports = function (config) {
// 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: ['HeadlessChrome'],
Expand All @@ -55,12 +36,22 @@ module.exports = function (config) {
}
},

preprocessors: {
// *Sigh* what a glob, folks!
'{{!(node_modules),*.js},!(node_modules)/**/*.js}': ['browserify']
},

browserify: {
debug: true,
transform: ['brfs']
},

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

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
concurrency: 1
});
};
25 changes: 6 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
],
"files": [
"src",
"dist/debug.js",
"LICENSE",
"README.md"
],
Expand All @@ -28,37 +27,25 @@
"lint": "xo",
"test": "npm run test:node && npm run test:browser",
"test:node": "istanbul cover _mocha -- test.js",
"posttest:node": "cat ./coverage/lcov.info | coveralls",
"pretest:browser": "npm run build",
"test:browser": "karma start --single-run",
"prebuild:debug": "mkdir -p dist && browserify --standalone debug -o dist/debug.es6.js .",
"build:debug": "babel -o dist/debug.js dist/debug.es6.js > dist/debug.js",
"build:test": "babel -d dist test.js",
"build": "npm run build:debug && npm run build:test",
"clean": "rimraf dist coverage"
"posttest:node": "cat ./coverage/lcov.info | coveralls"
},
"dependencies": {
"ms": "^2.1.1"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"browserify": "16.2.3",
"chai": "^4.2.0",
"concurrently": "^4.1.0",
"brfs": "^2.0.1",
"browserify": "^16.2.3",
"coveralls": "^3.0.2",
"istanbul": "^0.4.5",
"karma": "^3.1.4",
"karma-chai": "^0.1.0",
"karma-mocha": "^1.3.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.2.0",
"rimraf": "^2.5.4",
"xo": "^0.23.0"
},
"main": "./src/index.js",
"browser": "./src/browser.js",
"unpkg": "./dist/debug.js"
"browser": "./src/browser.js"
}
52 changes: 21 additions & 31 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
/* eslint-env mocha */
'use strict';

let chai;

let expect;

let debug;

if (typeof module !== 'undefined') {
chai = require('chai');
expect = chai.expect;
debug = require('./src');
}
const assert = require('assert');
const debug = require('./src');

describe('debug', () => {
it('passes a basic sanity check', () => {
const log = debug('test');
log.enabled = true;
log.log = () => {};

expect(() => log('hello world')).to.not.throw();
assert.doesNotThrow(() => log('hello world'));
});

it('allows namespaces to be a non-string value', () => {
const log = debug('test');
log.enabled = true;
log.log = () => {};

expect(() => debug.enable(true)).to.not.throw();
assert.doesNotThrow(() => debug.enable(true));
});

it('honors global debug namespace enable calls', () => {
expect(debug('test:12345').enabled).to.equal(false);
expect(debug('test:67890').enabled).to.equal(false);
assert.deepStrictEqual(debug('test:12345').enabled, false);
assert.deepStrictEqual(debug('test:67890').enabled, false);

debug.enable('test:12345');
expect(debug('test:12345').enabled).to.equal(true);
expect(debug('test:67890').enabled).to.equal(false);
assert.deepStrictEqual(debug('test:12345').enabled, true);
assert.deepStrictEqual(debug('test:67890').enabled, false);
});

it('uses custom log function', () => {
Expand All @@ -50,7 +40,7 @@ describe('debug', () => {
log('using custom log function again');
log('%O', 12345);

expect(messages.length).to.equal(3);
assert.deepStrictEqual(messages.length, 3);
});

describe('extend namespace', () => {
Expand All @@ -60,7 +50,7 @@ describe('debug', () => {
log.log = () => {};

const logBar = log.extend('bar');
expect(logBar.namespace).to.be.equal('foo:bar');
assert.deepStrictEqual(logBar.namespace, 'foo:bar');
});

it('should extend namespace with custom delimiter', () => {
Expand All @@ -69,7 +59,7 @@ describe('debug', () => {
log.log = () => {};

const logBar = log.extend('bar', '--');
expect(logBar.namespace).to.be.equal('foo--bar');
assert.deepStrictEqual(logBar.namespace, 'foo--bar');
});

it('should extend namespace with empty delimiter', () => {
Expand All @@ -78,46 +68,46 @@ describe('debug', () => {
log.log = () => {};

const logBar = log.extend('bar', '');
expect(logBar.namespace).to.be.equal('foobar');
assert.deepStrictEqual(logBar.namespace, 'foobar');
});
});

describe('rebuild namespaces string (disable)', () => {
it('handle names, skips, and wildcards', () => {
debug.enable('test,abc*,-abc');
const namespaces = debug.disable();
expect(namespaces).to.equal('test,abc*,-abc');
assert.deepStrictEqual(namespaces, 'test,abc*,-abc');
});

it('handles empty', () => {
debug.enable('');
const namespaces = debug.disable();
expect(namespaces).to.equal('');
expect(debug.names).to.deep.equal([]);
expect(debug.skips).to.deep.equal([]);
assert.deepStrictEqual(namespaces, '');
assert.deepStrictEqual(debug.names, []);
assert.deepStrictEqual(debug.skips, []);
});

it('handles all', () => {
debug.enable('*');
const namespaces = debug.disable();
expect(namespaces).to.equal('*');
assert.deepStrictEqual(namespaces, '*');
});

it('handles skip all', () => {
debug.enable('-*');
const namespaces = debug.disable();
expect(namespaces).to.equal('-*');
assert.deepStrictEqual(namespaces, '-*');
});

it('names+skips same with new string', () => {
debug.enable('test,abc*,-abc');
const oldNames = [...debug.names];
const oldSkips = [...debug.skips];
const namespaces = debug.disable();
expect(namespaces).to.equal('test,abc*,-abc');
assert.deepStrictEqual(namespaces, 'test,abc*,-abc');
debug.enable(namespaces);
expect(oldNames.map(String)).to.deep.equal(debug.names.map(String));
expect(oldSkips.map(String)).to.deep.equal(debug.skips.map(String));
assert.deepStrictEqual(oldNames.map(String), debug.names.map(String));
assert.deepStrictEqual(oldSkips.map(String), debug.skips.map(String));
});
});
});

0 comments on commit 6489766

Please sign in to comment.