Skip to content
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

process.cwd() not programmatically friendly #96

Open
cblanquera opened this issue Nov 12, 2014 · 4 comments
Open

process.cwd() not programmatically friendly #96

cblanquera opened this issue Nov 12, 2014 · 4 comments

Comments

@cblanquera
Copy link

https://github.com/phonegap/connect-phonegap/blob/master/lib/middleware/autoreload.js#L21

Please allow options to override the cwd as in

watches = [ path.join(options.projectDir || process.cwd(), 'www/**/*') ];
@cblanquera
Copy link
Author

This is now linked to: phonegap/phonegap-cli#477

I know i should've fork/pull this, but it's like a one liner :(

@mwbrooks mwbrooks added this to the Maintenance 2015 milestone Sep 16, 2015
@mwbrooks mwbrooks modified the milestones: Maintenance, User Support May 30, 2016
@ngryman
Copy link

ngryman commented Oct 20, 2016

Same comment I posted in phonegap/phonegap-cli#477

Hi, any idea when this would be available?

It's really a blocker when you want to integrate it with parallel build systems. You can't process.chdir without messing up other tasks. Depending on cwd certainly makes sense for a CLI but is a really bad idea when you expose an programmatic API (i.e. connect-phonegap).
It totally defeats the purpose of using the API because obviously you want to integrate this with other tools that may need your cwd to stay where it is.

As @mwbrooks mentioned, it should be an easy fix with a maximum gain. Could you prioritize this? That would be awesome! 💖

@filmaj
Copy link
Collaborator

filmaj commented Apr 21, 2017

It looks like cwd is used extensively:

~/src/connect-phonegap on master via ⬢ v6.10.1
➔ ack cwd
lib/middleware/autoreload.js
24:        watches = [ path.join(process.cwd(), 'www/**/*') ];

lib/middleware/browser.js
34:    if (options.phonegap && fs.existsSync(path.join(process.cwd(), 'platforms/browser'))) {
39:    return connect.static(path.join(process.cwd(), 'platforms/browser/www'));
54:    if (options.phonegap && !fs.existsSync(path.join(process.cwd(), 'platforms/browser'))) {

lib/middleware/static.js
15:    return connect.static(path.join(process.cwd(), 'www'));

lib/middleware/update.js
51:                var output = filename.split(process.cwd())[1];

lib/middleware/zip.js
64:                var theWalker = walk(path.join(process.cwd(), 'www'), {'follow_symlinks': true});
72:                    var output = pathWithSymlinks(filename).split(process.cwd())[1];

So all of these modules would need the extension y'all suggested above, FYI.

@ngryman
Copy link

ngryman commented Apr 22, 2017

@filmaj I'm proposing a little refactoring: process.cwd() -> options.cwd || process.cwd().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants