jasmine-node
Advanced tools
Comparing version 1.7.1 to 1.8.0
@@ -38,3 +38,4 @@ var walkdir = require('walkdir'); | ||
exports.start = function(loadpaths, pattern) { | ||
exports.start = function(loadpaths, watchFolders, patterns) { | ||
var watchPatterns; | ||
@@ -46,4 +47,7 @@ loadpaths.forEach(function(loadpath){ | ||
if (stats.isFile()) { | ||
console.log(loadpath); | ||
pattern = loadpath; | ||
watchPatterns = loadpath; | ||
} else { | ||
watchPatterns = patterns.map(function(p) { | ||
return path.join(loadpath, p); | ||
}); | ||
} | ||
@@ -76,3 +80,3 @@ | ||
gaze(pattern, function(err, watcher) { | ||
gaze(watchPatterns, function(err, watcher) { | ||
// Get all watched files | ||
@@ -85,5 +89,33 @@ console.log("Watching for changes in " + loadpath); | ||
}) | ||
run_everything(); | ||
} | ||
}); | ||
watchFolders.forEach(function(watchPath) { | ||
// If watchPath is just a single file, we should just watch that file | ||
stats = fs.statSync(watchPath); | ||
if (stats.isFile()) { | ||
watchPatterns = watchPath; | ||
} else { | ||
watchPatterns = patterns.map(function(p) { | ||
return path.join(watchPath, p); | ||
}); | ||
} | ||
// We debounce run_everything here due to the Vim issue described above. | ||
var onChanged = _.debounce(run_everything, 2500, true); | ||
gaze(watchPatterns, function(err, watcher) { | ||
console.log("Watching for changes in " + watchPath); | ||
this.on('all', onChanged); | ||
}); | ||
}); | ||
run_everything(); | ||
}; |
@@ -17,2 +17,3 @@ var util, | ||
var specFolders = []; | ||
var watchFolders = []; | ||
@@ -108,2 +109,15 @@ // The following line keeps the jasmine setTimeout in the proper scope | ||
break; | ||
case '--watch': | ||
var nextWatchDir; | ||
// Add the following arguments, until we see another argument starting with '-' | ||
while (args[0] && args[0][0] !== '-') { | ||
nextWatchDir = args.shift(); | ||
watchFolders.push(nextWatchDir); | ||
if (!existsSync(nextWatchDir)) | ||
throw new Error("Watch path '" + watchDir + "' doesn't exist!"); | ||
} | ||
break; | ||
case '--forceexit': | ||
@@ -152,15 +166,10 @@ forceExit = true; | ||
if (autotest) { | ||
//TODO: this is ugly, maybe refactor? | ||
var glob = specFolders.map(function(path){ | ||
return Path.join(path, '**/*.js'); | ||
}); | ||
var patterns = ['**/*.js']; | ||
if (extentions.indexOf("coffee") !== -1) { | ||
glob = glob.concat(specFolders.map(function(path){ | ||
return Path.join(path, '**/*.coffee') | ||
})); | ||
patterns.push('**/*.coffee'); | ||
} | ||
require('./autotest').start(specFolders, glob); | ||
require('./autotest').start(specFolders, watchFolders, patterns); | ||
@@ -231,2 +240,3 @@ return; | ||
, ' --autotest - rerun automatically the specs when a file changes' | ||
, ' --watch PATH - when used with --autotest, watches the given path(s) and runs all tests if a change is detected' | ||
, ' --color - use color coding for output' | ||
@@ -233,0 +243,0 @@ , ' --noColor - do not use color coding for output' |
{ | ||
"name": "jasmine-node", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"description": "DOM-less simple JavaScript BDD testing framework for Node", | ||
@@ -8,6 +8,3 @@ "contributors": [ | ||
], | ||
"homepage": [ | ||
"http://pivotal.github.com/jasmine", | ||
"https://github.com/mhevery/jasmine-node" | ||
], | ||
"homepage": "https://github.com/mhevery/jasmine-node", | ||
"repository": { | ||
@@ -22,3 +19,6 @@ "type": "git", | ||
"author": "Misko Hevery <misko@hevery.com>", | ||
"maintainers": "Martin Häger <martin.haeger@gmail.com>", | ||
"maintainers": [ | ||
"Martin Häger <martin.haeger@gmail.com>", | ||
"Chris Moultrie <chris@moultrie.org>" | ||
], | ||
"licenses": [ | ||
@@ -25,0 +25,0 @@ "MIT" |
@@ -63,2 +63,4 @@ jasmine-node | ||
* <code>--autotest</code>, provides automatic execution of specs after each change | ||
* <code>--watch</code>, when used with <code>--autotest</code>, paths after <code>--watch</code> will be | ||
watched for changes, allowing to watch for changes outside of specs directory | ||
* <code>--coffee</code>, allow execution of .coffee and .litcoffee specs | ||
@@ -147,2 +149,4 @@ * <code>--color</code>, indicates spec output should uses color to | ||
* _1.8.0 - Fixed bug in autotest with multiple paths and added --watch feature | ||
(thanks to [davegb3](https://github.com/davegb3))_ | ||
* _1.7.1 - Removed unneeded fs dependency (thanks to | ||
@@ -149,0 +153,0 @@ [kevinsawicki](https://github.com/kevinsawicki)) Fixed broken fs call in |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
149931
4077
166