Skip to content

Commit

Permalink
add jshint and jscs
Browse files Browse the repository at this point in the history
  • Loading branch information
manrueda committed Oct 3, 2015
1 parent b07303a commit 71db0ad
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
12 changes: 12 additions & 0 deletions .jscsrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"requireSemicolons": true,
"requireParenthesesAroundIIFE": true,
"maximumLineLength": 120,
"validateLineBreaks": "LF",
"validateIndentation": 2,
"disallowTrailingComma": true,
"disallowSpacesInsideObjectBrackets": null,
"disallowImplicitTypeConversion": ["string"],
"safeContextKeyword": "that",
"validateQuoteMarks": "'"
}
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ env:

script:
- npm install
- grunt
- npm test
- npm run cov
before_script:
- npm install tape -g
- npm install grunt-cli tape -g
22 changes: 22 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jscs: {
src: ['*.js', 'src/**/*.js', 'test/**/*.js'],
options: {
config: '.jscsrc.json'
}
},
jshint: {
all: ['*.js', 'src/**/*.js', 'test/**/*.js']
}
});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jscs');

grunt.registerTask('default', ['jshint', 'jscs']);

};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"homepage": "https://github.com/ManRueda/zip-mapper#readme",
"devDependencies": {
"coveralls": "^2.11.4",
"grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.11.3",
"grunt-jscs": "^2.1.0",
"istanbul": "^0.3.21",
"tape": "^4.2.0"
},
Expand Down
6 changes: 3 additions & 3 deletions src/ZipMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports.prototype.cleanTemp = function(cb){
fs.unlink(that.tempDir, function(){
that.tempDir = '';
if (cb){
cb
cb();
}
});
}
Expand Down Expand Up @@ -142,7 +142,7 @@ function memoryOutput(zipPath, cb) {

function validateParameters(path, onMemory, cb){
var err;
if (path === undefined || path == ''){
if (path === undefined || path === ''){
err = new Error('The zip file is empty.');
}else{
var stat = fs.statSync(path);
Expand All @@ -152,7 +152,7 @@ function validateParameters(path, onMemory, cb){
}
if (err){
if (cb){
cb(err)
cb(err);
}else{
throw err;
}
Expand Down
5 changes: 2 additions & 3 deletions test/simpleTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ test('should export the files into a temp folder and return a object represent i
var mapper = new ZipMapper(filePath, function(err, map){
t.equal(err, undefined, 'The first parameter must be undefined');
t.notEqual(map, undefined, 'The second parameter must be an object');

t.true(map instanceof Object, 'The second parameter must be an object');
t.true(map.folder1 instanceof Object, 'This property must be an object with the child files');
t.equal(typeof map['file1.js'], 'string', 'This property must be a string with the path to the file');
Expand All @@ -38,12 +37,12 @@ test('should export the files to memory and return a object represent it', funct
var mapper = new ZipMapper(filePath, true, function(err, map){
t.equal(err, undefined, 'The first parameter must be undefined');
t.notEqual(map, undefined, 'The second parameter must be an object');

t.true(map instanceof Object, 'The second parameter must be an object');
t.true(map.folder1 instanceof Object, 'This property must be an object with the child files');
t.true(map['file1.js'] instanceof Buffer, 'This property must be a Buffer with the file content');
t.equal(map['file1.js'].toString('UTF-8'), 'File1 Content\n', 'The file content must be \'File1 Content\n\'');
t.true(map.folder1['file1.js'] instanceof Buffer, 'This property must be a Buffer with the file content');
t.equal(map.folder1['file1.js'].toString('UTF-8'), 'File1 in folder1 content\n', 'The file content must be \'File1 in folder1 content\n\'');
var auxMsg = 'The file content must be \'File1 in folder1 content\n\'';
t.equal(map.folder1['file1.js'].toString('UTF-8'), 'File1 in folder1 content\n', auxMsg);
});
});

0 comments on commit 71db0ad

Please sign in to comment.