From 5283fd346bc241f385a864bbde6a0d7c0dd2b8b3 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 2 Dec 2015 07:13:55 -0800 Subject: [PATCH 1/2] Updated linter --- .jshintrc | 20 ---------------- lib/git.js | 1 - lib/index.js | 18 +++++++------- lib/util.js | 2 +- package.json | 12 +++++++--- tasks.js | 56 ------------------------------------------- test/.jshintrc | 26 -------------------- test/lib/util.spec.js | 1 + 8 files changed, 21 insertions(+), 115 deletions(-) delete mode 100644 .jshintrc delete mode 100644 tasks.js delete mode 100644 test/.jshintrc diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 3dbf635d..00000000 --- a/.jshintrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "curly": true, - "eqeqeq": true, - "indent": 2, - "latedef": true, - "newcap": true, - "nonew": true, - "quotmark": "single", - "undef": true, - "trailing": true, - "maxlen": 80, - "globals": { - "Buffer": false, - "exports": true, - "module": false, - "process": false, - "require": false, - "__dirname": false - } -} \ No newline at end of file diff --git a/lib/git.js b/lib/git.js index ad96a1bc..af3c8b70 100644 --- a/lib/git.js +++ b/lib/git.js @@ -8,7 +8,6 @@ var fs = require('q-io/fs'); var git = 'git'; - /** * @constructor * @param {number} code Error code. diff --git a/lib/index.js b/lib/index.js index 201ff818..61f7bef1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,7 +6,6 @@ var wrench = require('wrench'); var _ = require('lodash'); var glob = require('glob'); -var pkg = require('../package.json'); var git = require('./git'); var copy = require('./util').copy; @@ -48,6 +47,9 @@ function getRepo(options) { /** * Push a git branch to a remote (pushes gh-pages by default). + * @param {string} basePath The base path. + * @param {Object} config Publish options. + * @param {Function} done Callback. */ exports.publish = function publish(basePath, config, done) { if (typeof config === 'function') { @@ -179,14 +181,14 @@ exports.publish = function publish(basePath, config, done) { var deferred = Q.defer(); git.tag(options.tag, options.clone) .then(function() { - return deferred.resolve(); - }) + return deferred.resolve(); + }) .fail(function(error) { - // tagging failed probably because this tag alredy exists - log('Tagging failed, continuing'); - options.logger(error); - return deferred.resolve(); - }); + // tagging failed probably because this tag alredy exists + log('Tagging failed, continuing'); + options.logger(error); + return deferred.resolve(); + }); return deferred.promise; } else { return Q.resolve(); diff --git a/lib/util.js b/lib/util.js index c3742dd2..f7180458 100644 --- a/lib/util.js +++ b/lib/util.js @@ -131,7 +131,7 @@ function makeDir(path, callback) { * @param {string} dest Destination directory. * @return {Promise} A promise. */ -var copy = exports.copy = function(files, base, dest) { +exports.copy = function(files, base, dest) { var deferred = Q.defer(); var pairs = []; diff --git a/package.json b/package.json index 62906e56..828fd89d 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ }, "main": "lib/index.js", "scripts": { - "test": "node tasks.js lint test" + "pretest": "eslint lib test", + "test": "mocha --recursive test" }, "dependencies": { "async": "0.2.9", @@ -35,11 +36,16 @@ "wrench": "1.5.1" }, "devDependencies": { - "mocha": "~1.18.2", + "chai": "~1.9.1", + "eslint": "^1.10.3", + "eslint-config-tschaub": "^2.0.0", "jshint": "~2.4.4", - "chai": "~1.9.1" + "mocha": "~1.18.2" }, "bin": { "gh-pages": "bin/gh-pages" + }, + "eslintConfig": { + "extends": "tschaub" } } diff --git a/tasks.js b/tasks.js deleted file mode 100644 index 6afd7a3d..00000000 --- a/tasks.js +++ /dev/null @@ -1,56 +0,0 @@ -var path = require('path'); - -var jshint = require('jshint/src/cli').run; -var glob = require('glob'); -var Mocha = require('mocha'); - - -/** - * Run the linter. - * @param {function(Error)} done Callback. - */ -exports.lint = function(done) { - var args = ['lib', 'test', 'tasks.js']; - var passed = jshint({args: args}); - process.nextTick(function() { - done(passed ? null : new Error('JSHint failed')); - }); -}; - - -/** - * Run the tests. - * @param {function(Error)} done Callback. - */ -exports.test = function(done) { - var mocha = new Mocha(); - mocha.reporter('spec'); - mocha.ui('bdd'); - mocha.files = glob.sync('test/**/*.spec.js').map(function(file) { - return path.resolve(file); - }); - mocha.run(function(failures) { - done(failures ? new Error('Mocha failures') : null); - }); -}; - - -var tasks = process.argv.slice(2); - -function run(current) { - var task = tasks[current]; - if (task) { - exports[task](function(err) { - if (err) { - process.stderr.write(err.message + '\n'); - process.exit(1); - } else { - ++current; - run(current); - } - }); - } else { - process.exit(0); - } -} -run(0); diff --git a/test/.jshintrc b/test/.jshintrc deleted file mode 100644 index ff66433f..00000000 --- a/test/.jshintrc +++ /dev/null @@ -1,26 +0,0 @@ -{ - "curly": true, - "eqeqeq": true, - "indent": 2, - "latedef": true, - "newcap": true, - "nonew": true, - "quotmark": "single", - "undef": true, - "trailing": true, - "maxlen": 80, - "globals": { - "Buffer": false, - "exports": true, - "before": false, - "beforeEach": false, - "after": false, - "afterEach": false, - "describe": false, - "it": false, - "module": false, - "process": false, - "require": false, - "__dirname": false - } -} \ No newline at end of file diff --git a/test/lib/util.spec.js b/test/lib/util.spec.js index 2ec1b8d7..f541c376 100644 --- a/test/lib/util.spec.js +++ b/test/lib/util.spec.js @@ -1,3 +1,4 @@ +/* eslint-env mocha */ var path = require('path'); var assert = require('../helper').assert; From 36b87f134045e93f90ff8a920dea6ceae9392170 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 2 Dec 2015 07:21:12 -0800 Subject: [PATCH 2/2] Updated deps --- package.json | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 828fd89d..3cdcddd7 100644 --- a/package.json +++ b/package.json @@ -26,21 +26,20 @@ "test": "mocha --recursive test" }, "dependencies": { - "async": "0.2.9", - "commander": "~2.8.1", + "async": "1.5.0", + "commander": "2.9.0", "glob": "~4.0.2", - "graceful-fs": "2.0.1", + "graceful-fs": "4.1.2", "lodash": "~2.4.1", - "q": "~1.0.1", - "q-io": "~1.11.0", - "wrench": "1.5.1" + "q": "1.4.1", + "q-io": "1.13.2", + "wrench": "1.5.8" }, "devDependencies": { - "chai": "~1.9.1", + "chai": "^3.4.1", "eslint": "^1.10.3", "eslint-config-tschaub": "^2.0.0", - "jshint": "~2.4.4", - "mocha": "~1.18.2" + "mocha": "^2.3.4" }, "bin": { "gh-pages": "bin/gh-pages"