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
Having trouble properly implementing ShellJS #1107
Comments
Try using You may need to adapt the syntax to work with |
So something like this??? var path = "C:/Users/someUser"
var file = "file.txt"
shell.find(file, { cwd: path }, (error, stdout, stderr) => {
var filePath = stdout.substring(stdout.indexOf("./") + 2).trim("\n");
if (error !== null) {
console.Log("Cannot Locate the File...");
console.log();
return;
} Sorry I'm very new to ShellJS EditI've cleaned up the code after reading the npm ShellJS documentation a few times over, hopefully that's close to what I need |
The callback is only available for I think you want something like: shell.cd(path);
var results = shell.find(file);
// "results" is like an array, but with some extra ShellString properties.
// Check .stderr or .code to determine success.
if (results.code !== 0) {
console.log(results.stderr);
} else {
// Assuming we're searching for an exact match rather than a wildcard pattern,
// then there should only be 1 element in the array.
var filePath = results[0];
} I haven't tested this, so you may need to tweak the code to get it the way you want. |
Thank you I'll check this out and let you know how I go |
nitpick:
please rename to "using ShellJS" |
G'day guys, I'm so sorry to bother you with such a silly question, I was wondering if anyone could help me out with properly implementing Shelljs into my project, I'm very new to shelljs and a little bit confused on the documentation of how it's implemented, basically all I want to do is allow the Unix
find
command and it's configuration from my NodeJS app shown below, to work cross platform with Windows... Instead of it just working on Mac & Linuxbut I don't know how to properly implement shelljs here, can anyone please help me out with how this is done, I've been trying at this for a while now!
The text was updated successfully, but these errors were encountered: