diff --git a/.jshintrc b/.jshintrc index 5fb94a0b..8a764469 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,6 +1,5 @@ { "node": true, - "esnext": true, "bitwise": true, "camelcase": true, "curly": true, diff --git a/package.json b/package.json index 33d4809f..a8d0c3b8 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ }, "dependencies": { "chalk": "~1.0.0", - "ejs": "^2.3.1", "lodash": "~3.7.0", "slash": "~1.0.0", "underscore.string": "~3.0.3", @@ -39,20 +38,22 @@ "bower": "~1.4.1", "chai": "~2.3.0", "chai-as-promised": "~5.0.0", - "commander": "^2.8.1", + "commander": "~2.8.1", "coveralls": "~2.11.2", "cross-spawn": "~0.4.0", "fixture-stdout": "~0.2.1", "istanbul": "~0.3.14", - "js-beautify": "^1.5.5", + "js-beautify": "~1.5.5", "mkdirp": "^0.5.1", "mocha": "~2.2.5", "mocha-lcov-reporter": "0.0.2", - "q": "^1.4.1", - "recursive-readdir": "^1.2.1", - "sinon": "^1.14.1", - "sinon-chai": "^2.7.0", - "wrench": "^1.5.8" + "recursive-readdir": "~1.2.1", + "sinon": "~1.14.1", + "sinon-chai": "~2.7.0", + "wrench": "1.5.8", + "ejs": "~2.3.1", + "mz": "~1.3.0", + "bluebird": "~2.9.25" }, "peerDependencies": { "yo": ">=1.0.0" diff --git a/test/inception.js b/test/inception.js index bd5f3ff9..60d72f73 100644 --- a/test/inception.js +++ b/test/inception.js @@ -1,12 +1,14 @@ 'use strict'; -var fs = require('fs'); +var fs = require('mz/fs'); var path = require('path'); -var spawn = require('cross-spawn'); -var q = require('q'); var _ = require('lodash'); +var spawn = require('cross-spawn'); +var Promise = require('bluebird'); var helpers = require('yeoman-generator').test; +var testDirectory = Promise.promisify(helpers.testDirectory); + var outputInTest = require('./mute'); var mockOptions = require('../app/src/mock-options.js'); var mockPrompts = require('../app/src/mock-prompts.js'); @@ -24,10 +26,10 @@ function prepare(optionCase, promptCase) { var options = _.extend({}, _.cloneDeep(mockOptions.defaults), optionCase, skipOptions); var prompts = _.extend({}, _.cloneDeep(mockPrompts.defaults), promptCase); - return q.nfcall(helpers.testDirectory, tempDir).then(function() { - return q.all([ - q.nfcall(fs.symlink, path.join(depsDir, 'node_modules'), path.join(tempDir, 'node_modules')), - q.nfcall(fs.symlink, path.join(depsDir, 'bower_components'), path.join(tempDir, 'bower_components')) + return testDirectory(tempDir).then(function() { + return Promise.all([ + fs.symlink(path.join(depsDir, 'node_modules'), path.join(tempDir, 'node_modules')), + fs.symlink(path.join(depsDir, 'bower_components'), path.join(tempDir, 'bower_components')) ]); }).then(function() { var gulpAngular = helpers.createGenerator( @@ -46,21 +48,19 @@ function prepare(optionCase, promptCase) { } function run(generator, task) { - var deferred = q.defer(); - - generator.conflicter.force = true; - generator.run(function () { - var gulpProcess = spawn('node', ['node_modules/gulp/bin/gulp.js', task], {stdio: 'inherit'}); - gulpProcess.on('exit', function(returnCode) { - if(returnCode === 0) { - deferred.resolve(); - } else { - deferred.reject('Gulp returned with error code ' + returnCode); - } + return new Promise(function(resolve, reject) { + generator.conflicter.force = true; + generator.run(function () { + var gulpProcess = spawn('node', ['node_modules/gulp/bin/gulp.js', task], {stdio: 'inherit'}); + gulpProcess.on('exit', function(returnCode) { + if(returnCode === 0) { + resolve(); + } else { + reject('Gulp returned with error code ' + returnCode); + } + }); }); }); - - return deferred.promise; } module.exports = { diff --git a/test/template-tools.js b/test/template-tools.js index 2bbd9200..b0ebf309 100644 --- a/test/template-tools.js +++ b/test/template-tools.js @@ -1,12 +1,12 @@ 'use strict'; /* jshint camelcase:false */ -var fs = require('fs'); +var fs = require('mz/fs'); +var Promise = require('bluebird'); var path = require('path'); -var mkdirp = require('mkdirp'); +var mkdirp = Promise.promisify(require('mkdirp')); var beautify = require('js-beautify').js_beautify; -var q = require('q'); -var readdir = require('recursive-readdir'); +var readdir = Promise.promisify(require('recursive-readdir')); var ejs = require('ejs'); var templatesDir = path.join(__dirname, '../app/templates/'); @@ -41,14 +41,14 @@ function compile(fileName) { var destinationFilePath = compiledTemplatesDir + fileName + compiledTemplatesSuffix; var destinationDir = path.dirname(destinationFilePath); - return q.all([ - q.nfcall(mkdirp, destinationDir), - q.nfcall(fs.readFile, sourceFilePath) + return Promise.all([ + mkdirp(destinationDir), + fs.readFile(sourceFilePath) ]).then(function(results) { var content = results[1].toString(); var sourceContent = sourceHeader + beautify(compileEjs(content), { indent_size: 2 }) + sourceFooter; sourceContent = sourceContent.replace('with(locals || {})', 'with(locals)'); - return q.nfcall(fs.writeFile, destinationFilePath, sourceContent); + return fs.writeFile(destinationFilePath, sourceContent); }); } @@ -66,9 +66,9 @@ function load(fileName) { } function prepare() { - return q.nfcall(readdir, templatesDir) + return readdir(templatesDir) .then(function(files) { - return q.all(files.filter(function(file) { + return Promise.all(files.filter(function(file) { var basename = path.basename(file); return /^_[^_]/.test(basename); }).map(function(file) { @@ -102,16 +102,16 @@ function deps() { return ejs.render(string, data); } - return q.all([ - q.nfcall(mkdirp, depsDir), - q.nfcall(fs.readFile, packagePath), - q.nfcall(fs.readFile, bowerPath) + return Promise.all([ + mkdirp(depsDir), + fs.readFile(packagePath), + fs.readFile(bowerPath) ]).then(function(results) { var packageFileContent = processTemplate(results[1]); var bowerFileContent = processTemplate(results[2]); - return q.all([ - q.nfcall(fs.writeFile, packageDestinationPath, packageFileContent), - q.nfcall(fs.writeFile, bowerDestinationPath, bowerFileContent) + return Promise.all([ + fs.writeFile(packageDestinationPath, packageFileContent), + fs.writeFile(bowerDestinationPath, bowerFileContent) ]); }) .catch(function(error) { diff --git a/test/template/test-index-module-js.js b/test/template/test-index-module-js.js index 77cf74a6..01d32afb 100644 --- a/test/template/test-index-module-js.js +++ b/test/template/test-index-module-js.js @@ -6,7 +6,7 @@ var sinonChai = require('sinon-chai'); chai.should(); chai.use(sinonChai); -var q = require('q'); +var Promise = require('bluebird'); var templateTools = require('../template-tools'); var mockModel = require('./mock-model'); @@ -15,7 +15,7 @@ describe('gulp-angular index js template', function () { var model, indexJs, indexEs6, indexCoffee, indexTs; before(function() { - return q.all([ + return Promise.all([ templateTools.load('src/app/_index.module.js'), templateTools.load('src/app/_index.module.es6'), templateTools.load('src/app/_index.module.coffee'),