Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Console/node/tasks/php_tests.js
Original file line number Diff line number Diff line change
@@ -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(); });
}
});
};
// 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(); });
// }
// });
// };
28 changes: 26 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -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'),
Expand All @@ -16,6 +17,9 @@ module.exports = function(grunt) {
}
}
},
phptestfile: {
target: {},
},

watch: {
php: {
Expand All @@ -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'],
Expand All @@ -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);
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "_PROJECT_NAME_",
"name": "@TODO:_PROJECT_NAME_",
"scripts": {
"start": "grunt dev"
},
Expand Down