-
Notifications
You must be signed in to change notification settings - Fork 0
/
npm.js
executable file
·34 lines (23 loc) · 894 Bytes
/
npm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// always return the same npm object. This is important, as
// programs might want to set the paths or other things.
var moduleName = __filename.replace(/\.js$/, '');
if (module.id !== moduleName) {
module.exports = require(moduleName);
return;
}
var npm = exports;
var utils = require("./lib/utils");
npm.moduleName = moduleName;
["install", "activate", "deactivate", "ls"].forEach(function (c) {
npm[c] = require("./lib/"+c);
});
npm.list = npm.ls;
var registry = {};
npm.set = set;
npm.get = get;
function set (name, data) { return utils.set(registry, name, data) };
function get (name) { return utils.get(registry, name) };
var path = require("path");
npm.root = path.join(process.env.HOME, ".node_libraries");
npm.__defineGetter__("dir", function () { return path.join(npm.root, ".npm") });
npm.__defineGetter__("tmp", function () { return path.join(npm.dir, ".tmp") });