-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to parse past path entries on D: #56
Labels
Comments
@johnkazer Just out of curiosity, what's the output you get if you run the following script? node that-script-below.js "use strict";
which("git").then(output => {
console.log(output);
});
/**
* Locate a program file in the user's $PATH.
*
* If found, the returned {@link Promise} resolves to the absolute
* pathname of the named executable. Otherwise, it resolves to the
* empty string. Rejects with an error if the execution failed.
*
* @example which("curl") == "/usr/bin/curl"
* @example which("nada") == ""
* @param {String} name
* @return {Promise}
*/
function which(name){
return new Promise((resolve, reject) => {
if(!name) return resolve("");
const {exec} = require("child_process");
const cmdStr = "win32" === process.platform
? `@for %g in (ECHO ${name.replace(/%/g, "%%")}) do`
+ " @for %e in (%PATHEXT%) do"
+ " @for %i in (%g%e) do "
+ ' @if NOT "%~$PATH:i"=="" echo %~$PATH:i'
: `command -v '${name.replace(/'/g, `'"'"'`)}' 2>/dev/null`;
exec(cmdStr, {windowsHide: true}, (error, output) => error
? reject(error)
: resolve(output.split(/\r?\n/).filter(Boolean)[0] || ""));
});
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have two path entries 'D:....' but whichSync failed to iterate over pathEnv beyond these when trying to find the 'git' path. I changed the order so the 'D:...' entries were last and whichSync parsed everything up to but not including those moved 'D:...' entries. When moved, there were the 14th and 15th path entries.
Didn't work:
Worked:
The text was updated successfully, but these errors were encountered: