Skip to content

Commit

Permalink
Build: Add eslint and jscs
Browse files Browse the repository at this point in the history
  • Loading branch information
pdehaan authored and phated committed Oct 2, 2017
1 parent 5a4e2d7 commit c232f0e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "gulp"
}
3 changes: 3 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "gulp"
}
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
sudo: false

language: node_js

node_js:
- 'stable'
- '0.12'
- '0.10'
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
'use strict';

function DefaultRegistry(){
if(this instanceof DefaultRegistry === false){
function DefaultRegistry() {
if (this instanceof DefaultRegistry === false) {
return new DefaultRegistry();
}

this._tasks = {};
}

DefaultRegistry.prototype.init = function init(taker){};
DefaultRegistry.prototype.init = function init(taker) {};

DefaultRegistry.prototype.get = function get(name){
DefaultRegistry.prototype.get = function get(name) {
return this._tasks[name];
};

DefaultRegistry.prototype.set = function set(name, fn){
DefaultRegistry.prototype.set = function set(name, fn) {
this._tasks[name] = fn;
};

DefaultRegistry.prototype.tasks = function tasks(){
DefaultRegistry.prototype.tasks = function tasks() {
var self = this;

return Object.keys(this._tasks).reduce(function(tasks, name){
return Object.keys(this._tasks).reduce(function(tasks, name) {
tasks[name] = self.get(name);
return tasks;
}, {});
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"description": "undertaker-registry ===================",
"main": "index.js",
"scripts": {
"lint": "eslint . && jscs index.js test/",
"pretest": "npm run lint",
"test": "lab -cv"
},
"repository": {
"type": "git",
"url": "https://github.com/phated/undertaker-registry"
"url": "https://github.com/gulpjs/undertaker-registry"
},
"keywords": [
"registry",
Expand All @@ -19,11 +21,15 @@
"author": "Blaine Bublitz <blaine@iceddev.com> (http://iceddev.com/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/phated/undertaker-registry/issues"
"url": "https://github.com/gulpjs/undertaker-registry/issues"
},
"homepage": "https://github.com/phated/undertaker-registry",
"homepage": "https://github.com/gulpjs/undertaker-registry",
"devDependencies": {
"code": "^1.2.1",
"eslint": "^1.7.3",
"eslint-config-gulp": "^2.0.0",
"jscs": "^2.4.0",
"jscs-preset-gulp": "^1.0.0",
"lab": "^6.2.0"
}
}
3 changes: 3 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "gulp/test"
}
26 changes: 13 additions & 13 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ var it = lab.it;

var Registry = require('../');

function noop(){}
function noop() {}

describe('undertaker-registry', function(){
describe('undertaker-registry', function() {

describe('constructor', function(){
describe('constructor', function() {

it('can be constructed with new', function(done){
it('can be constructed with new', function(done) {
var reg = new Registry();
expect(reg.get).to.be.a.function();
expect(reg.set).to.be.a.function();
expect(reg.tasks).to.be.a.function();
done();
});

it('can be constructed without new', function(done){
it('can be constructed without new', function(done) {
var reg = Registry();
expect(reg.get).to.be.a.function();
expect(reg.set).to.be.a.function();
Expand All @@ -31,38 +31,38 @@ describe('undertaker-registry', function(){
});
});

describe('init', function(){
describe('init', function() {

it('is a noop', function(done){
it('is a noop', function(done) {
var reg = new Registry();
expect(reg.init).to.be.a.function();
done();
});
});

describe('get', function(){
describe('get', function() {

it('returns a task from the registry', function(done){
it('returns a task from the registry', function(done) {
var reg = new Registry();
reg._tasks.test = noop;
expect(reg.get('test')).to.equal(noop);
done();
});
});

describe('set', function(){
describe('set', function() {

it('registers a task', function(done){
it('registers a task', function(done) {
var reg = new Registry();
reg.set('test', noop);
expect(reg._tasks.test).to.equal(noop);
done();
});
});

describe('tasks', function(){
describe('tasks', function() {

it('returns an object of task name->functions', function(done){
it('returns an object of task name->functions', function(done) {
var reg = new Registry();
reg.set('test1', noop);
reg.set('test2', noop);
Expand Down

0 comments on commit c232f0e

Please sign in to comment.