Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fuck you, npm, I'll do what I want!

I needed things to be done synchronously, so I rolled my own.
  • Loading branch information...
commit 1df756b9e44dc58ee1283d012eea298822b7021f 1 parent 5507d9a
@mattrobenolt mattrobenolt authored
Showing with 17 additions and 20 deletions.
  1. +16 −18 lib/utils.js
  2. +1 −2  package.json
View
34 lib/utils.js
@@ -1,9 +1,7 @@
var raven = require('./client'),
crypto = require('crypto'),
fs = require('fs'),
- url = require('url'),
- // this makes me feel dirty. :(
- readInstalled = require(__dirname+'/../node_modules/npm/lib/utils/read-installed.js');
+ url = require('url');
module.exports.constructChecksum = function constructChecksum(kwargs) {
var checksum = crypto.createHash('md5');
@@ -47,27 +45,27 @@ module.exports.parseDSN = function parseDSN(dsn) {
}
};
-var module_cache = false;
-module.exports.getModules = function getModules(callback) {
+var module_cache;
+module.exports.getModules = function getModules() {
if(module_cache) {
- return callback(module_cache);
+ return module_cache;
}
- readInstalled('.', function(err, list) {
- if (err) {
- // uh oh, ignore silently
return callback({});
- }
- module_cache = {};
- for(var module in list.dependencies) {
- var m = list.dependencies[module];
- module_cache[m.name] = m.version;
- }
- cb(module_cache);
+ var path = require('path');
+ var cwd = path.resolve('.');
+ var folders = fs.readdirSync(path.join(cwd, './node_modules/'));
+ folders = folders.filter(function(f){
+ return f.charAt(0) !== '.';
});
+ module_cache = {};
+ folders.forEach(function(folder) {
+ try {
+ var json = require(path.join(cwd, './node_modules/'+folder+'/package.json'));
+ module_cache[json.name] = json.version;
+ });
+ return module_cache;
};
-module.exports.getModules = function(){ return module_cache; };
-
var LINES_OF_CONTEXT = 7;
/*
View
3  package.json
@@ -13,8 +13,7 @@
"node": ">= 0.6.0"
},
"dependencies": {
- "node-uuid": "*",
- "npm": "*"
+ "node-uuid": "*"
},
"devDependencies": {
"connect": "*",
Please sign in to comment.
Something went wrong with that request. Please try again.