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

Replace in files on network drive? #56

Closed
jschuman opened this issue Aug 13, 2018 · 8 comments
Closed

Replace in files on network drive? #56

jschuman opened this issue Aug 13, 2018 · 8 comments
Assignees

Comments

@jschuman
Copy link

jschuman commented Aug 13, 2018

I'm having some trouble getting this to work on files on a network drive.

For example, I set my files attribute to something like this:
let files = "\\\\share_name\\Users\\Public\\jschuman\\*.html"

but no file replacements occur (and I know there should be).

Is this possible?

@jschuman jschuman changed the title Replace files on network drive? Replace in files on network drive? Aug 13, 2018
@adamreisnz
Copy link
Owner

@jschuman thanks for reporting, I think your issue may be similar to #32

Could you try using the disableGlobs: true flag and see if that helps?

@jschuman
Copy link
Author

ok, that does work but I am (not surprisingly) unable to then use my *.html wildcard as in my example above. The parent folder has thousands of files I am looking through for replacement so guessing I am just out-of-luck for now?

@adamreisnz
Copy link
Owner

Yes I see what you mean. Unfortunately I am unable to test this myself as I don't have access to any windows machines or network drives.

Would you be able to look into this and dig deeper to see if you can find a solution?

Maybe this thread can help: isaacs/node-glob#74

@adamreisnz
Copy link
Owner

Perhaps it's sufficient if we allow you to pass in the cwd parameter to the glob options?

@jschuman
Copy link
Author

jschuman commented Aug 14, 2018

As a followup, I did get this working as a POC locally (at least for the sync version). It was fairly straightforward and, yes, @adamreisnz it was really just a question of supporting the cwd parameter. Unfortunately, with our use case the performance was intolerable when applying to the network drive vs. copying and performing locally so it's really infeasible for our use case.

Here's a summation of what I found in case I have time to create a PR later or someone else has the time. Again, this was just a POC to get working with the sync function, so a more thorough solution is definitely needed:

  • updated replaceInFile.sync to support the cwd option
  • updated getPathsSync to add cwd option to the config; but only if present
  • updated getPathsSync to also preface each path returned by glob.sync with the cwd (if present) before returning paths

That was what was needed to support the cwd parameter, and then my use of replace-in-file had to be adjusted in the following way:

  • when using UNC, I set the cwd parameter to the UNC path (i.e., \\\\share_name\\Users\\Public\\jschuman\\)
  • the files parameter was then set with the wildcard (e.g. to **/*.html for my use case)

I hope this helps.

@adamreisnz
Copy link
Owner

Thanks @jschuman, if I have time myself I'll look at implementing support for the cwd flag.

@adamreisnz
Copy link
Owner

@jschuman I have added support for the cwd parameter in 4.0.0, would you mind taking it for a spin and see if it resolves the issue you had?

adamreisnz added a commit that referenced this issue Apr 21, 2019
* Bump dependencies

* [feature] #38 Count number of matches

* Update make-replacements.js

* [feature] #42 Differentiate number of matches and number of replacements

* [enhance] #56 Support for CWD parameter

* Default config value

* [enhance] #63 Add --quiet flag to supress console output in CLI

* Update success-handler.js

* Update readme and add change log
@adamreisnz
Copy link
Owner

@jschuman I'll close this issue now, but if you have a minute and can check if the new version works for you that'd be great.

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

No branches or pull requests

2 participants