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 'lib/explore.js')
-rw-r--r--lib/explore.js38
1 files changed, 22 insertions, 16 deletions
diff --git a/lib/explore.js b/lib/explore.js
index 452be6d72..105ff84cc 100644
--- a/lib/explore.js
+++ b/lib/explore.js
@@ -3,32 +3,38 @@
module.exports = explore
explore.usage = 'npm explore <pkg> [ -- <cmd>]'
-explore.completion = require("./utils/completion/installed-shallow.js")
+explore.completion = require('./utils/completion/installed-shallow.js')
-var npm = require("./npm.js")
- , spawn = require("./utils/spawn")
- , path = require("path")
- , fs = require("graceful-fs")
- , log = require("npmlog")
+var npm = require('./npm.js')
+var spawn = require('./utils/spawn')
+var path = require('path')
+var 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]
+ args = args.join(' ').trim()
+ if (args) args = ['-c', args]
else args = []
var cwd = path.resolve(npm.dir, p)
- var sh = npm.config.get("shell")
+ 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")
+ if (er || !s.isDirectory()) {
+ return cb(new Error(
+ "It doesn't look like " + p + ' is installed.'
+ ))
+ }
- var shell = spawn(sh, args, { cwd: cwd, stdio: "inherit" })
- shell.on("close", function (er) {
+ if (!args.length) {
+ console.log(
+ '\nExploring ' + cwd + '\n' +
+ "Type 'exit' or ^D when finished\n"
+ )
+ }
+
+ 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)