alltheversions
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -12,6 +12,6 @@ "use strict"; | ||
exec(command, function (err, res) { | ||
var data = res && res.toString("utf8"); | ||
err ? reject(data || err) : resolve(data || ""); | ||
var data = res && res.toString("utf8") || ""; | ||
err ? reject(data) : resolve(data); | ||
}); | ||
}); | ||
}; |
@@ -7,4 +7,2 @@ "use strict"; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
@@ -14,4 +12,2 @@ | ||
var EventEmitter = require("events").EventEmitter; | ||
var Promise = _interopRequire(require("bluebird")); | ||
@@ -27,20 +23,12 @@ | ||
var Module = (function (_EventEmitter) { | ||
var Module = (function () { | ||
function Module(mod, version, emitter) { | ||
_classCallCheck(this, Module); | ||
this.emitter = emitter; | ||
this.version = version; | ||
this.name = mod.name; | ||
this.task = mod.task || "npm test"; | ||
if (emitter) { | ||
forward(this, emitter, "uninstall"); | ||
forward(this, emitter, "install"); | ||
forward(this, emitter, "pass"); | ||
forward(this, emitter, "fail"); | ||
} | ||
} | ||
_inherits(Module, _EventEmitter); | ||
_createClass(Module, { | ||
@@ -52,3 +40,6 @@ uninstall: { | ||
return rimraf("node_modules/" + this.name).then(function (res) { | ||
_this.emit("uninstall", _this); | ||
if (_this.emitter) { | ||
_this.emitter.emit("uninstall", _this, res); | ||
} | ||
return _this; | ||
@@ -65,3 +56,6 @@ }, function () { | ||
return exec("npm install " + this.name + "@" + this.version).then(function (res) { | ||
_this.emit("install", _this); | ||
if (_this.emitter) { | ||
_this.emitter.emit("install", _this, res); | ||
} | ||
return _this; | ||
@@ -78,6 +72,18 @@ }, function () { | ||
return exec(this.task).then(function (res) { | ||
_this.emit("pass", _this, res); | ||
_this.passed = true; | ||
_this.result = res; | ||
if (_this.emitter) { | ||
_this.emitter.emit("pass", _this, res); | ||
} | ||
return _this; | ||
}, function (err) { | ||
_this.emit("fail", _this, err); | ||
}, function (res) { | ||
_this.passed = false; | ||
_this.result = res; | ||
if (_this.emitter) { | ||
_this.emitter.emit("fail", _this, res); | ||
} | ||
return _this; | ||
@@ -101,9 +107,14 @@ }); | ||
value: function matchingSpec(mod, emitter) { | ||
var range = mod.range || "*"; | ||
return exec("npm view " + mod.name + " versions").then(function (res) { | ||
return JSON.parse(res.replace(/\'/g, "\"")).filter(function (version) { | ||
return satisfies(version, mod.range); | ||
}).map(function (version) { | ||
var list = JSON.parse(res.replace(/\'/g, "\"")).reverse(); | ||
if (typeof mod.range !== "undefined") { | ||
list = list.filter(function (version) { | ||
return satisfies(version, mod.range); | ||
}); | ||
} | ||
return list.map(function (version) { | ||
return new Module(mod, version, emitter); | ||
}).reverse(); | ||
}); | ||
}); | ||
@@ -131,3 +142,3 @@ } | ||
return Module; | ||
})(EventEmitter); | ||
})(); | ||
@@ -139,21 +150,10 @@ module.exports = Module; | ||
// | ||
function forward(src, dest, type) { | ||
src.on(type, function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
dest.emit.apply(dest, [type].concat(args)); | ||
}); | ||
} | ||
function satisfies(version, ranges) { | ||
if (!Array.isArray(ranges)) { | ||
ranges = [ranges]; | ||
return semver.satisfies(version, ranges); | ||
} | ||
return ranges.reduce(function (memo, range) { | ||
return memo || semver.satisfies(version, range); | ||
return ranges.reduce(function (m, r) { | ||
return m || semver.satisfies(version, r); | ||
}, false); | ||
} |
@@ -20,18 +20,18 @@ "use strict"; | ||
ev.on("pass", function (mod, res) { | ||
function extra(out) { | ||
if (options.verbose) { | ||
console.log("\n" + indent(out, " ", 4) + "\n"); | ||
} | ||
} | ||
ev.on("pass", function (mod, out) { | ||
checkModule(mod); | ||
console.log(" \u001b[32m✓\u001b[0m " + mod.version); | ||
if (options.verbose) { | ||
console.log("\n" + indent(res, " ", 4) + "\n"); | ||
} | ||
extra(out); | ||
}); | ||
ev.on("fail", function (mod, err) { | ||
ev.on("fail", function (mod, out) { | ||
checkModule(mod); | ||
console.log(" \u001b[31m✖\u001b[0m " + mod.version); | ||
if (options.verbose) { | ||
console.log("\n" + indent(err, " ", 4) + "\n"); | ||
} | ||
extra(out); | ||
}); | ||
@@ -38,0 +38,0 @@ |
@@ -0,1 +1,4 @@ | ||
// | ||
// This is used to run a list of promises in serial, *not* parallel | ||
// | ||
"use strict"; | ||
@@ -14,4 +17,2 @@ | ||
return fn(item); | ||
})["catch"](function (e) { | ||
return console.log("dafuq?", e.stack); | ||
}); | ||
@@ -18,0 +19,0 @@ }); |
@@ -6,2 +6,5 @@ var gulp = require('gulp') | ||
var ATV = require('./dist') | ||
var spec = require('./dist/reporters/spec') | ||
gulp.task('test', function () { | ||
@@ -15,2 +18,11 @@ return gulp.src('test/**/*.js', { read: false }) | ||
gulp.task('versions', function (cb) { | ||
ATV.testWithVersions({ | ||
name: 'bluebird', | ||
range: '2.x' | ||
}, spec({ | ||
verbose: true | ||
})).then(cb.bind(null, null), cb) | ||
}) | ||
gulp.task('build', function () { | ||
@@ -17,0 +29,0 @@ return gulp.src('lib/**/*.js') |
{ | ||
"name": "alltheversions", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Run your tests against ALL THE VERSIONS!", | ||
@@ -5,0 +5,0 @@ "author": "Stephen Belanger <admin@stephenbelanger.com>", |
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
35
3
11163
316