diff --git a/Console/node/tasks/php_tests.js b/Console/node/tasks/php_tests.js index ef7e332..e92d6c9 100644 --- a/Console/node/tasks/php_tests.js +++ b/Console/node/tasks/php_tests.js @@ -1,17 +1,17 @@ var fs = require('fs'); -module.exports = function(grunt) { - grunt.event.on('watch', function(action, filepath) { - var CakeTestRunner, regex = /\.php$/; - if (regex.test(filepath)) { - CakeTestRunner = require('../cake_test_runner'), - file = new CakeTestRunner(filepath); - - if (fs.existsSync('.vagrant')) { //@TODO: This doesn't work because the folder shows up inside the VM too. - file.vagrantHost = true; - } - - file.exists(function() { file.run(); }); - } - }); -}; \ No newline at end of file +// module.exports = function(grunt) { +// grunt.event.on('watch', function(action, filepath) { +// var CakeTestRunner, regex = /\.php$/; +// if (regex.test(filepath)) { +// CakeTestRunner = require('../cake_test_runner'), +// file = new CakeTestRunner(filepath); +// +// if (fs.existsSync('.vagrant')) { //@TODO: This doesn't work because the folder shows up inside the VM too. +// file.vagrantHost = true; +// } +// +// file.exists(function() { file.run(); }); +// } +// }); +// }; \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 803542a..8c9bfe9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,7 @@ module.exports = function(grunt) { grunt.loadTasks('Console/node/tasks'); require('load-grunt-tasks')(grunt); + var fs = require('fs'); grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), @@ -16,6 +17,9 @@ module.exports = function(grunt) { } } }, + phptestfile: { + target: {}, + }, watch: { php: { @@ -26,7 +30,11 @@ module.exports = function(grunt) { '!tmp/**', '!.git/**/*.php' ], - tasks: 'null' // See Console/node/tasks/php_tests.js +// tasks: 'null', // See Console/node/tasks/php_tests.js + tasks: ['phptestfile'], + options: { + spawn: false + } }, less: { files: ['webroot/less/**/*.less'], @@ -37,4 +45,20 @@ module.exports = function(grunt) { grunt.registerTask('default', ['less', 'watch']); grunt.registerTask('test', ['jstest']); // See Console/node/tasks/js_tests.js -}; + + grunt.registerMultiTask('phptestfile', function() { + var files = this.filesSrc; + var CakeTestRunner = require('./Console/node/cake_test_runner'); + var phpfile; + var vagrantHost = fs.existsSync('.vagrant'); + + files.forEach(function(filepath) { + phpfile = new CakeTestRunner(filepath); + phpfile.vagrantHost = vagrantHost; + phpfile.exists(function() { phpfile.run(); }); + }); + + // Otherwise, print a success message. + grunt.log.ok('Files tested: ' + files.length); + }); +} diff --git a/package.json b/package.json index fb81185..bd2e95d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "_PROJECT_NAME_", + "name": "@TODO:_PROJECT_NAME_", "scripts": { "start": "grunt dev" },