question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

shell.which returns object

See original GitHub issue

Node version (or tell us if you’re using electron or some other framework):

Using Shell.js in an Atom (1.34) plugin, => Electron 2.0.12

ShellJS version (the most recent version/Github branch you see the bug on):

0.8.3

Operating system:

macOS

Description of the bug:

shell.which('command') returns an object instead of a string

Example ShellJS command to reproduce the error:

const test = shell.which('git')
console.log(typeof test) // yields 'object' instead of 'string'

Current workaround (hack) until fix is available

let test = shell.which('git')
if (test) {
  test = JSON.parse(JSON.stringify(test))
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nfischercommented, Mar 1, 2019

By design, this returns a ShellString. For your use-case, just call shell.which('git').toString().

0reactions
chrispahmcommented, Mar 5, 2019

@nfischer thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to manipulate what `shell.which()` returns? - Stack Overflow
How can I manipulate what shell.which() returns? One approach that I could take would be to manipulate require('shelljs') to load my own fork...
Read more >
Shell object (Shldisp.h) - Win32 apps | Microsoft Learn
Creates and returns a ShellWindows object. This object represents a collection of all of the open windows that belong to the Shell.
Read more >
2. Shell Command Language
The shell performs redirection (see Redirection) and removes redirection operators and their operands from the parameter list. The shell executes a function ( ......
Read more >
Bash Reference Manual - GNU.org
The return value is the exit status of the last command in commands that is executed, or false if any of the expressions...
Read more >
Child process | Node.js v19.3.0 Documentation
child_process.exec() : spawns a shell and runs a command within that shell, ... it returns a Promise for an Object with stdout and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found