10000 Move tasks into separate folder and fix JSCS/JSHint by tbranyen · Pull Request #48 · f/delorean · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Move tasks into separate folder and fix JSCS/JSHint #48

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

Merged
merged 2 commits into from
Nov 6, 2014
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
103 changes: 5 additions & 98 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,106 +1,13 @@
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-docco');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jscs-checker');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-release');
'use strict';

module.exports = function (grunt) {
grunt.initConfig({

pkg: grunt.file.readJSON('package.json'),

jshint: {
options: {
laxbreak: true
},
all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', '!test/vendor/**/*.js']
},
jscs: {
src: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', '!test/vendor/**/*.js'],
options: {
config: '.jscsrc',
validateIndentation: 2,
disallowDanglingUnderscores: null,
disallowMultipleVarDecl: null,
requireMultipleVarDecl: null
}
},
docco: {
dist: {
src: ['src/*.js'],
options: {
output: 'docs/api/'
}
}
},
karma: {
unit: {
configFile: 'test/karma.conf.js'
}
},
browserify: {
dist: {
files: {
'dist/.tmp/delorean-requirements.js': 'src/requirements.js'
}
}
},
concat: {
options: {
separator: ';',
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: ['src/delorean.js', 'dist/.tmp/delorean-requirements.js'],
dest: 'dist/delorean.js'
}
},
uglify: {
options: {
sourceMap: true,
mangle: {
except: ['DeLorean', 'Store', 'Dispatcher', 'Flux']
}
},
build: {
files: {
'dist/delorean.min.js': ['dist/delorean.js']
}
}
},
connect: {
server: {
options: {
livereload: true,
port: 9001,
base: 'coverage/'
}
}
},
watch: {
development: {
files: ['!src/index.js', 'src/**/*.js', 'test/**/*.js'],
tasks: ['default'],
options: {
livereload: true
}
}
},
release: {
options: {
files: ['package.json', 'bower.json']
}
}
pkg: grunt.file.readJSON('package.json')
});

grunt.loadTasks('build/tasks');

grunt.registerTask('default', ['jscs', 'jshint', 'browserify', 'concat', 'uglify']);
grunt.registerTask('test', ['karma', 'docco']);
grunt.registerTask('dev', ['connect', 'watch']);

};
13 changes: 13 additions & 0 deletions 10000 build/tasks/browserify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

module.exports = function(grunt) {
grunt.config('browserify', {
dist: {
files: {
'dist/.tmp/delorean-requirements.js': 'src/requirements.js'
}
}
});

grunt.loadNpmTasks('grunt-browserify');
};
17 changes: 17 additions & 0 deletions build/tasks/concat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

module.exports = function(grunt) {
grunt.config('concat', {
options: {
separator: ';',
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: ['src/delorean.js', 'dist/.tmp/delorean-requirements.js'],
dest: 'dist/delorean.js'
}
});

grunt.loadNpmTasks('grunt-contrib-concat');
};
15 changes: 15 additions & 0 deletions build/tasks/connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = function(grunt) {
grunt.config('connect', {
server: {
options: {
livereload: true,
port: 9001,
base: 'coverage/'
}
}
});

grunt.loadNpmTasks('grunt-contrib-connect');
};
14 changes: 14 additions & 0 deletions build/tasks/docco.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

module.exports = function(grunt) {
grunt.config('docco', {
dist: {
src: ['src/*.js'],
options: {
output: 'docs/api/'
}
}
});

grunt.loadNpmTasks('grunt-docco');
};
16 changes: 16 additions & 0 deletions build/tasks/jscs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

module.exports = function(grunt) {
grunt.config('jscs', {
src: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', '!test/vendor/**/*.js'],
options: {
config: '.jscsrc',
validateIndentation: 2,
disallowDanglingUnderscores: null,
disallowMultipleVarDecl: null,
requireMultipleVarDecl: null
}
});

grunt.loadNpmTasks('grunt-jscs-checker');
};
14 changes: 14 additions & 0 deletions build/tasks/jshint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

module.exports = function(grunt) {
grunt.config('jshint', {
options: {
laxbreak: true,
node: true,
eqnull: true
},
all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', '!test/vendor/**/*.js']
});

grunt.loadNpmTasks('grunt-contrib-jshint');
};
11 changes: 11 additions & 0 deletions build/tasks/karma.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = function(grunt) {
grunt.config('karma', {
unit: {
configFile: 'test/karma.conf.js'
}
});

grunt.loadNpmTasks('grunt-karma');
};
11 changes: 11 additions & 0 deletions build/tasks/release.js
F438
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = function(grunt) {
grunt.config('release', {
options: {
files: ['package.json', 'bower.json']
}
});

grunt.loadNpmTasks('grunt-release');
};
19 changes: 19 additions & 0 deletions build/tasks/uglify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

module.exports = function(grunt) {
grunt.config('uglify', {
options: {
sourceMap: true,
mangle: {
except: ['DeLorean', 'Store', 'Dispatcher', 'Flux']
}
},
build: {
files: {
'dist/delorean.min.js': ['dist/delorean.js']
}
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');
};
15 changes: 15 additions & 0 deletions build/tasks/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = function(grunt) {
grunt.config('watch', {
development: {
files: ['!src/index.js', 'src/**/*.js', 'test/**/*.js'],
tasks: ['default'],
options: {
livereload: true
}
}
});

grunt.loadNpmTasks('grunt-contrib-watch');
};
24 changes: 13 additions & 11 deletions src/delorean.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
function __findDispatcher(view) {
// Provide a useful error message if no dispatcher is found in the chain
if (view == null) {
throw 'No disaptcher found. The DeLoreanJS mixin requires a "dispatcher" property to be passed to a component, or one of it\'s ancestors.'
throw 'No disaptcher found. The DeLoreanJS mixin requires a "dispatcher" property to be passed to a component, or one of it\'s ancestors.';
}
/* `view` should be a component instance. If a component don't have
any dispatcher, it tries to find a dispatcher from the parents. */
Expand Down Expand Up @@ -228,15 +228,15 @@
var changedProps = [];
if (typeof arg1 === 'object') {
for (var keyName in arg1) {
changedProps.push(keyName)
changedProps.push(keyName);
this.setValue(keyName, arg1[keyName]);
}
} else {
changedProps.push(arg1);
this.setValue(arg1, value);
}
this.recalculate(changedProps);
},
};

// `set` method updates the data defined at the `scheme` of the store.
Store.prototype.setValue = function (key, value) {
Expand Down Expand Up @@ -266,7 +266,9 @@
Store.prototype.formatScheme = function (scheme) {
var formattedScheme = {}, definition, defaultValue, calculatedValue;
for (var keyName in scheme) {
definition = scheme[keyName], defaultValue = null, calculatedValue = null;
definition = scheme[keyName];
defaultValue = null;
calculatedValue = null;

formattedScheme[keyName] = {default: null};

Expand All @@ -282,7 +284,7 @@
if (definition.deps) {
formattedScheme[keyName].deps = definition.deps;
} else {
formattedScheme[keyName].deps = []
formattedScheme[keyName].deps = [];
}

} else if (typeof definition === 'function') {
Expand Down Expand Up @@ -322,7 +324,7 @@
if (dependencyMap[dep] == null) {
dependencyMap[dep] = [];
}
dependencyMap[dep].push(keyName)
dependencyMap[dep].push(keyName);
}

this.store[__generateOriginalName(keyName)] = definition.default;
Expand Down Expand Up @@ -387,7 +389,7 @@
if (__hasOwn(this.store.actions, actionName)) {
callback = this.store.actions[actionName];
if (typeof this.store[callback] !== 'function') {
throw 'Callback "' + callback + '" defined for action "' + actionName + '" should be a method defined on the store!';
throw 'Callback \'' + callback + '\' defined for action \'' + actionName + '\' should be a method defined on the store!';
}
/* And `actionName` should be a name generated by `__generateActionName` */
this.listener.on(__generateActionName(actionName),
Expand Down Expand Up @@ -527,7 +529,7 @@
this.__changeHandlers = {};

/* Generate and bind the change handlers to the stores. */
for (var storeName in this.__watchStores) {
for (storeName in this.__watchStores) {
if (__hasOwn(this.stores, storeName)) {
store = this.stores[storeName];
this.__changeHandlers[storeName] = __changeHandler(store, storeName);
Expand Down Expand Up @@ -565,10 +567,10 @@
// You can use `this.stores` from the React component.
this.stores = this.__dispatcher.stores;

this.__watchStores = {}
this.__watchStores = {};
if (this.watchStores != null) {
for (var i = 0; i < this.watchStores.length; i++) {
storeName = this.watchStores[i]
storeName = this.watchStores[i];
this.__watchStores[storeName] = this.stores[storeName];
}
} else {
Expand All @@ -587,7 +589,7 @@
/* Set `state.stores` for all present stores with a `setState` method defined. */
for (var storeName in this.__watchStores) {
if (__hasOwn(this.stores, storeName)) {
store = this.__watchStores[storeName].store
store = this.__watchStores[storeName].store;
if (store && store.getState) {
state.stores[storeName] = store.getState();
} else if (typeof store.scheme === 'object') {
Expand Down
Loading
0