Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/activate.js')
-rw-r--r--scripts/activate.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/activate.js b/scripts/activate.js
new file mode 100644
index 000000000..990ded0e4
--- /dev/null
+++ b/scripts/activate.js
@@ -0,0 +1,17 @@
+#!/usr/local/bin/node
+var fs = require("fs"),
+ version = process.env["npm.package.version"],
+ bin = "/usr/local/bin/npm",
+ versionedBin = "/usr/local/bin/npm-"+version;
+
+fs.lstat(bin, function (er, st) {
+ if (er) fs.unlink(bin, linkBin);
+ else linkBin();
+});
+
+function linkBin (er) {
+ if (er) throw er;
+ fs.symlinkSync(versionedBin, bin, function (er) {
+ if (er) throw er;
+ });
+}