Skip to content

Instantly share code, notes, and snippets.

@ralphtheninja
Last active December 11, 2015 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralphtheninja/4637488 to your computer and use it in GitHub Desktop.
Save ralphtheninja/4637488 to your computer and use it in GitHub Desktop.
var npm = require('npm')
, fs = require('fs')
, rimraf = require('rimraf')
, _ = require('underscore')
, skipVersions = [ '0.2.1' ]
, moduleBase = __dirname + '/node_modules/'
, levelupBase = moduleBase + 'levelup'
if (fs.existsSync(levelupBase)) {
rimraf.sync(levelupBase)
}
npm.load({}, function (err, npm) {
npm.commands.info(['levelup'], getInfo)
})
function getInfo(err, info) {
if (err) return
var blob = Object.keys(info)[0]
if (blob.versions && blob.versions.length) {
installVersions(blob.versions)
benchmarkVersions(blob.versions)
}
}
function installVersions(versions) {
function install(v, cb) {
var levelupInstall = 'levelup@' + v
, folder = moduleBase + levelupInstall
if (!_.contains(skipVersions, v) && !fs.existsSync(folder)) {
npm.commands.install([ levelupInstall ], function(err) {
if (err) {
cb(err)
}
else {
fs.rename(levelupBase, folder, function(err) {
cb(err ? err : null)
})
}
})
}
else
cb(null)
}
function installer(i) {
if (i < versions.length) {
install(versions[i], function(err) {
if (err)
console.log(err)
else
installer(i+1)
})
}
}
installer(0)
}
function benchmarkVersions(versions) {
}
{
"predef": [ "assert", "refute", "define" ]
, "boss": true
, "bitwise": true
, "shadow": true
, "trailing": true
, "immed": true
, "latedef": false
, "forin": false
, "curly": false
, "debug": true
, "devel": false
, "evil": true
, "regexp": false
, "undef": true
, "sub": true
, "white": false
, "trailing": true
, "asi": true
, "laxbreak": true
, "eqnull": true
, "browser": true
, "node": true
, "laxcomma": true
, "proto": true
, "expr": true
, "es5": true
, "esnext": true
, "strict": false
, "onevar": true
}
magnus@emachines|22:12|~/src/levelup-benchmark (master) $ jshint --config .jshintrc index.js
index.js: line 17, col 17, 'getInfo' was used before it was defined.
index.js: line 26, col 25, 'installVersions' was used before it was defined.
index.js: line 62, col 27, 'benchmarkVersions' was used before it was defined.
3 errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment