jasmine-node
Advanced tools
Comparing version 1.0.18 to 1.0.19
@@ -10,2 +10,3 @@ var jasmine = require('./index'); | ||
var helperCollection = require('./spec-collection'); | ||
@@ -23,2 +24,3 @@ var specFolder = null; | ||
var match = '.'; | ||
var autotest = false; | ||
var useHelpers = true; | ||
@@ -78,2 +80,5 @@ | ||
break; | ||
case '--autotest': | ||
autotest = true; | ||
break; | ||
case '-h': | ||
@@ -92,2 +97,8 @@ help(); | ||
if (autotest) { | ||
require('./autotest').start(specFolder, | ||
new RegExp(".+\\.(" + extentions + ")$", "i")); | ||
return; | ||
} | ||
var exitCode = 0; | ||
@@ -111,2 +122,9 @@ | ||
helperCollection.load(specFolder, new RegExp(match + "spec\\.(" + extentions + ")$", 'i')); | ||
if(helperCollection.getSpecs().length === 0) { | ||
match = ""; | ||
} | ||
if(useHelpers){ | ||
@@ -131,2 +149,3 @@ jasmine.loadHelpersInFolder(specFolder, | ||
, 'Options:' | ||
, ' --autotest - rerun automatically the specs when a file changes' | ||
, ' --color - use color coding for output' | ||
@@ -133,0 +152,0 @@ , ' --noColor - do not use color coding for output' |
@@ -1,101 +0,28 @@ | ||
var fs = require('fs'), | ||
createSpecObj = function(path, root) { | ||
return { | ||
path: function() { return path; }, | ||
relativePath: function() { return path.replace(root, '').replace(/^[\/\\]/, ''); }, | ||
directory: function() { return path.replace(/[\/\\][\s\w\.-]*$/, ""); }, | ||
relativeDirectory: function() { return relativePath().replace(/[\/\\][\s\w\.-]*$/, ""); }, | ||
filename: function() { return path.replace(/^.*[\\\/]/, ''); } | ||
}; | ||
}, | ||
getFiles = function(dir) { | ||
if(isDir(dir)){ | ||
try { | ||
return fs.readdirSync(dir); | ||
} catch (err) { | ||
if(err.code === 'ENOENT') { | ||
return []; | ||
} else { | ||
throw err; | ||
} | ||
} | ||
} else { | ||
return []; | ||
} | ||
}, | ||
isFile = function(path) { | ||
var isFile = false; | ||
var findit = require('findit'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var specs = []; | ||
// fs.fstatSync will pass ENOENT from stat(2) up | ||
// the stack. That's not particularly useful right now, | ||
// so try and continue... | ||
try { | ||
isFile = fs.statSync(path).isFile(); | ||
} catch (err) { | ||
if (err.code === 'ENOENT') { | ||
isFile = false; | ||
} else { | ||
throw err; | ||
} | ||
} | ||
var createSpecObj = function(path, root) { | ||
return { | ||
path: function() { return path; }, | ||
relativePath: function() { return path.replace(root, '').replace(/^[\/\\]/, ''); }, | ||
directory: function() { return path.replace(/[\/\\][\s\w\.-]*$/, ""); }, | ||
relativeDirectory: function() { return relativePath().replace(/[\/\\][\s\w\.-]*$/, ""); }, | ||
filename: function() { return path.replace(/^.*[\\\/]/, ''); } | ||
}; | ||
}; | ||
return isFile; | ||
}, | ||
isDir = function(path) { | ||
var isDir = false; | ||
exports.load = function(loadpath, matcher) { | ||
// fs.fstatSync will pass ENOENT from stat(2) up | ||
// the stack. That's not particularly useful right now, | ||
// so try and continue... | ||
try { | ||
isDir = fs.statSync(path).isDirectory(); | ||
} catch (err) { | ||
if (err.code === 'ENOENT') { | ||
isDir = false; | ||
} else { | ||
throw err; | ||
} | ||
} | ||
var wannaBeSpecs = findit.sync(loadpath) | ||
return isDir; | ||
}, | ||
getAllSpecFiles = function(path, matcher, root) { | ||
var specs = []; | ||
if (isFile(path) && path.match(matcher)) { | ||
specs.push(createSpecObj(path, root)); | ||
} else if(isDir(path)) { | ||
var files = getFiles(path); | ||
for (var i = 0, len = files.length; i < len; i++) { | ||
var filename = path + '/' + files[i]; | ||
if(isFile(filename) && filename.match(matcher)) { | ||
specs.push(createSpecObj(filename, root)); | ||
} else if (isDir(filename)) { | ||
var subFiles = getAllSpecFiles(filename, matcher); | ||
subFiles.forEach(function(result) { | ||
specs.push(result); | ||
}); | ||
for (var i = 0; i < wannaBeSpecs.length; i++) { | ||
var file = wannaBeSpecs[i]; | ||
if (fs.statSync(file).isFile()) { | ||
if (matcher.test(path.basename(file))) { | ||
specs.push(createSpecObj(file)); | ||
} | ||
} | ||
} | ||
return specs; | ||
}, | ||
specs = []; | ||
exports.load = function(path, matcher) { | ||
var root; | ||
if (isDir(path)) { | ||
root = path; | ||
} else { | ||
root = path.replace(/[\/\\][\s\w\.-]*$/, ""); | ||
} | ||
getAllSpecFiles(path, matcher, root).forEach(function(s){ | ||
specs.push(s); | ||
}); | ||
} | ||
}; | ||
@@ -102,0 +29,0 @@ |
{ | ||
"name" : "jasmine-node" | ||
, "version" : "1.0.18" | ||
, "version" : "1.0.19" | ||
, "description" : "DOM-less simple JavaScript BDD testing framework for Node" | ||
@@ -22,2 +22,3 @@ , "homepage" : [ "http://pivotal.github.com/jasmine" | ||
, "requirejs" : ">=0.27.1" | ||
, "findit" : ">= 0.1.2" | ||
} | ||
@@ -24,0 +25,0 @@ , "bin" : "bin/jasmine-node" |
@@ -32,2 +32,4 @@ jasmine-node | ||
* <code>--autotest</code>, provides automatic execution of specs after | ||
each changes | ||
* <code>--coffee</code>, allow execution of .coffee specs | ||
@@ -34,0 +36,0 @@ * <code>--color</code>, indicates spec output should uses color to |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
140334
37
3433
57
4
12
1
+ Addedfindit@>= 0.1.2
+ Addedfindit@2.0.0(transitive)