Permalink
Browse files

chore(release): jshint the files before release

Add JSHint checking to the source files and clean them up to conform to
the .jshintrc file. Added the grunt task to support this.
  • Loading branch information...
1 parent 6c54096 commit 1c37e2d0691530ab4fa7a730e00acebd12566955 @eddiemonge eddiemonge committed Mar 27, 2014
Showing with 64 additions and 39 deletions.
  1. +16 −14 .jshintrc
  2. +26 −4 Gruntfile.js
  3. +4 −4 decorator/index.js
  4. +18 −17 util.js
View
@@ -1,16 +1,18 @@
{
- "node": true,
- "esnext": true,
- "bitwise": false,
- "curly": false,
- "eqeqeq": true,
- "eqnull": true,
- "immed": true,
- "latedef": true,
- "newcap": true,
- "noarg": true,
- "undef": true,
- "strict": false,
- "trailing": true,
- "smarttabs": true
+ "node": true,
+ "esnext": true,
+ "bitwise": false,
+ "curly": false,
+ "eqeqeq": true,
+ "eqnull": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "undef": true,
+ "strict": false,
+ "globalstrict": true,
+ "trailing": true,
+ "smarttabs": true,
+ "node": true
}
View
@@ -6,7 +6,20 @@ module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
+ pkg: require('./package.json'),
+ jshint: {
+ all: {
+ options: {
+ jshintrc: './.jshintrc'
+ },
+ src: [
+ '**/index.js',
+ '*.js',
+ '!test/**/*.js',
+ '!node_modules/**/*.js'
+ ]
+ }
+ },
changelog: {
options: {
dest: 'CHANGELOG.md',
@@ -44,17 +57,26 @@ module.exports = function (grunt) {
}
var config = setup(options.file, type);
- grunt.file.write(config.file, JSON.stringify(config.pkg, null, ' ') + '\n');
+ grunt.file.write(
+ config.file,
+ JSON.stringify(config.pkg, null, ' ') + '\n'
+ );
grunt.log.ok('Version bumped to ' + config.newVersion);
});
- grunt.registerTask('stage', 'git add files before running the release task', function () {
+ grunt.registerTask('stage', 'git adds files', function () {
var files = this.options().files;
grunt.util.spawn({
cmd: process.platform === 'win32' ? 'git.cmd' : 'git',
args: ['add'].concat(files)
}, grunt.task.current.async());
});
- grunt.registerTask('default', ['bump', 'changelog', 'stage', 'release']);
+ grunt.registerTask('default', [
+ 'jshint',
+ 'bump',
+ 'changelog',
+ 'stage',
+ 'release'
+ ]);
};
View
@@ -3,6 +3,10 @@ var util = require('util');
var ScriptBase = require('../script-base.js');
var fs = require('fs');
+function buildRelativePath(fileName){
+ return 'decorators/' + fileName + "Decorator";
+}
+
var Generator = module.exports = function Generator(args, options) {
ScriptBase.apply(this, arguments);
this.fileName = this.name;
@@ -61,7 +65,3 @@ Generator.prototype.createDecoratorFiles = function createDecoratorFiles() {
this.appTemplate('decorator', 'scripts/' + buildRelativePath(this.fileName));
this.addScriptToIndex(buildRelativePath(this.fileName));
};
-
-function buildRelativePath(fileName){
- return 'decorators/' + fileName + "Decorator";
-}
View
@@ -2,28 +2,12 @@
var path = require('path');
var fs = require('fs');
-
-module.exports = {
- rewrite: rewrite,
- rewriteFile: rewriteFile,
- appName: appName
-};
-
-function rewriteFile (args) {
- args.path = args.path || process.cwd();
- var fullPath = path.join(args.path, args.file);
-
- args.haystack = fs.readFileSync(fullPath, 'utf8');
- var body = rewrite(args);
-
- fs.writeFileSync(fullPath, body);
-}
-
function escapeRegExp (str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}
function rewrite (args) {
+ /* jshint -W044 */
// check if splicable is already in the body text
var re = new RegExp(args.splicable.map(function (line) {
return '\s*' + escapeRegExp(line);
@@ -59,6 +43,16 @@ function rewrite (args) {
return lines.join('\n');
}
+function rewriteFile (args) {
+ args.path = args.path || process.cwd();
+ var fullPath = path.join(args.path, args.file);
+
+ args.haystack = fs.readFileSync(fullPath, 'utf8');
+ var body = rewrite(args);
+
+ fs.writeFileSync(fullPath, body);
+}
+
function appName (self) {
var counter = 0, suffix = self.options['app-suffix'];
// Have to check this because of generator bug #386
@@ -72,3 +66,10 @@ function appName (self) {
}
return suffix ? self._.classify(suffix) : '';
}
+
+
+module.exports = {
+ rewrite: rewrite,
+ rewriteFile: rewriteFile,
+ appName: appName
+};

0 comments on commit 1c37e2d

Please sign in to comment.