forked from sanyaade-mobiledev/cocoafish-node-sdk
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NODEJS-1767] Make type dectection way better
- Make type dectection way better - Apply JSHint into practice
- Loading branch information
Showing
6 changed files
with
106 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,67 @@ | ||
var spawn = require('child_process').spawn, | ||
BIN = './node_modules/.bin/'; | ||
|
||
module.exports = function(grunt) { | ||
// Configure Grunt | ||
grunt.initConfig({ | ||
jshint: { | ||
options: { | ||
jshintrc: true | ||
}, | ||
src: ['lib/**/*.js'] | ||
src: ['lib/**/*.js', '*.js'] | ||
}, | ||
clean: { | ||
pre: ['*.log'], | ||
post: ['tmp'] | ||
} | ||
}); | ||
|
||
// Register task of mocha test | ||
grunt.registerTask('mocha', 'mocha test', function() { | ||
var done = this.async(); | ||
// var proc = spawn(BIN + 'mocha', ['--bail']); | ||
var proc = spawn(BIN + 'mocha'); | ||
proc.stdout.on('data', function(data) { | ||
process.stdout.write(data); | ||
}); | ||
proc.stderr.on('data', function(data) { | ||
process.stderr.write(data); | ||
}); | ||
proc.on('close', function(code) { | ||
if (code !== 0) { | ||
grunt.fail.fatal('fail'); | ||
} else { | ||
grunt.log.ok('done'); | ||
} | ||
done(); | ||
}); | ||
}); | ||
|
||
// Register task of test coverage | ||
grunt.registerTask('coverage', 'generate test coverage report', function() { | ||
var done = this.async(); | ||
var proc = spawn(BIN + 'istanbul', ['cover', '--root', 'lib', '_mocha', '--', '-R', 'spec']); | ||
proc.stdout.on('data', function(data) { | ||
process.stdout.write(data); | ||
}); | ||
proc.stderr.on('data', function(data) { | ||
process.stderr.write(data); | ||
}); | ||
proc.on('close', function(code) { | ||
if (code !== 0) { | ||
grunt.fail.fatal('fail'); | ||
} else { | ||
grunt.log.ok('done'); | ||
} | ||
done(); | ||
}); | ||
}); | ||
|
||
// Load grunt plugins | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
|
||
// Register tasks | ||
grunt.registerTask('default', ['jshint']); | ||
grunt.registerTask('default', ['clean:pre', 'mocha', 'jshint', 'clean:post']); | ||
grunt.registerTask('cover', ['clean:pre', 'coverage', 'clean:post']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters