]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/explore.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / lib / explore.js
diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/explore.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/explore.js
new file mode 100644 (file)
index 0000000..96475a0
--- /dev/null
@@ -0,0 +1,37 @@
+// npm explore <pkg>[@<version>]
+// open a subshell to the package folder.
+
+module.exports = explore
+explore.usage = "npm explore <pkg> [ -- <cmd>]"
+explore.completion = require("./utils/completion/installed-shallow.js")
+
+var npm = require("./npm.js")
+  , spawn = require("./utils/spawn")
+  , path = require("path")
+  , fs = require("graceful-fs")
+
+function explore (args, cb) {
+  if (args.length < 1 || !args[0]) return cb(explore.usage)
+  var p = args.shift()
+  args = args.join(" ").trim()
+  if (args) args = ["-c", args]
+  else args = []
+
+  var cwd = path.resolve(npm.dir, p)
+  var sh = npm.config.get("shell")
+  fs.stat(cwd, function (er, s) {
+    if (er || !s.isDirectory()) return cb(new Error(
+      "It doesn't look like "+p+" is installed."))
+    if (!args.length) console.log(
+      "\nExploring "+cwd+"\n"+
+      "Type 'exit' or ^D when finished\n")
+
+    npm.spinner.stop()
+    var shell = spawn(sh, args, { cwd: cwd, stdio: "inherit" })
+    shell.on("close", function (er) {
+      // only fail if non-interactive.
+      if (!args.length) return cb()
+      cb(er)
+    })
+  })
+}