Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #13 from alexstrat/master

[new feature] Monitor mode : specify a command to execute before reload browser and rerun specs
  • Loading branch information...
commit e13da4fdf50a4d7b261741eb7608a404a5bc60da 2 parents 27b5258 + d87742f
Andreas Maierhofer amaierhofer authored
4 README.md
View
@@ -31,6 +31,10 @@ Specifies where to load source files from
### spec_dir
Specifies where to load specs from
+### mon
+####build_cmd
+In monitor mode : specify here a command to execute when files change but before browser reloads and specs rerun. For example a build command.
+
### externals
An array of miscelanious scripts to include, like jquery
3  lib/jasmine-runner.js
View
@@ -41,7 +41,8 @@
}
var server = require('server').newServer(config);
server.start();
- require('monitor').startMonitor(server);
+ build_cmd = (typeof config.mon != 'undefined') ? config.mon.build_cmd : undefined;
+ require('monitor').startMonitor(server, build_cmd);
});
},
ci:function(){
21 lib/monitor.js
View
@@ -9,7 +9,7 @@ var fs = require('fs'),
fs.writeFileSync(flag, '');
-var startMonitor = function(server) {
+var startMonitor = function(server, build_cmd) {
var cmd = 'find . -type f -newer ' + flag + ' -print';
setInterval(function(){
exec(cmd, function (error, stdout, stderr) {
@@ -22,8 +22,23 @@ var startMonitor = function(server) {
if (files.length) {
var files = files.filter(function(f){ return f.match(/(.js|.coffee)$/) });
if (server && files.length) {
- console.log('[monitor] sending reload command');
- server.rerun();
+
+ if(typeof build_cmd != 'undefined') {
+ console.log("[monitor] executing command : '"+build_cmd+"'")
+ exec(build_cmd, function(error, stdout, stderr){
+ if(error || stderr) return;
+
+ (stdout = stdout.split(/\n/)).pop();
+ console.log(stdout.join('\n'));
+
+ fs.writeFileSync(flag, '');
+ console.log('[monitor] sending reload command');
+ server.rerun();
+ });
+ }else{
+ console.log('[monitor] sending reload command');
+ server.rerun();
+ }
}
}
}
3  lib/template/jasmine.json
View
@@ -1,6 +1,9 @@
{
"src_dir" : "/public/javascript/",
"spec_dir" : "/spec/",
+ "mon" : {
+ "build_cmd" : "echo 'building instruction executing....'"
+ },
"server":{
"port":8124
},
Please sign in to comment.
Something went wrong with that request. Please try again.