browserstack / browserstack-local-nodejs

NodeJS bindings for BrowserStack Local
https://www.browserstack.com
MIT License
71 stars 56 forks source link

Using '~' in the binarypath argument doesn't work correctly. #28

Closed shanep2300 closed 7 years ago

shanep2300 commented 7 years ago

Trying to make the path point inside the project folder so I try to use: '~/binaries/BrowserStackLocal.exe'

The test fails and says there is not such directory found in: 'C:/Users//Documents//~/binaries/BrowserStackLocal.exe'

Using version 1.3.0 on Windows 7.

pulkitsharma07 commented 7 years ago

Hi, node has issues using ~ in paths. Have a look here https://github.com/nodejs/node/issues/684. As mentioned you can use os.homedir().

shanep2300 commented 7 years ago

Hmm, I'm getting the same issue where it adds the home directory correctly but os.homedir() is still found inside the path: Error: ENOENT: no such file or directory, unlink 'C:\Users\<user>\Documents\<project>\os.homedir()\binaries\BrowserStackLocal.exe'

Here it is with the ~. Error: ENOENT: no such file or directory, unlink 'C:\Users\<user>\Documents\<project>\~binaries\BrowserStackLocal.exe'. Taking out the / before binaries from op, fixed the extra / showing up in the path. But the ~ is included just like os.homedir() is.

pulkitsharma07 commented 7 years ago

it seems like you are passing os.homedir() inside the path, you need to call that method and add the value it returns inside your path. I hope this is clear. This code snippet should help.

 console.log(os.homedir());
 var binary_path = os.homedir() + "\\binaries\\BrowserStackLocal.exe";
 console.log(binary_path);

You can run the above code snippet using node to see if it prints the desired information.

shanep2300 commented 7 years ago

Perfect! Thank you very much!

shanep2300 commented 7 years ago

Update fix:

var path = require('path'); 'binarypath': path.resolve(process.cwd()) +'/binaries/BrowserStackLocal.exe'

This, gives the working directory as os.homedir() points to C:\, in my instance, which ultimately I wanted to avoid using if test is used on different machines.