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

fix: file globing #785

Merged
merged 10 commits into from
Feb 5, 2023
Merged

fix: file globing #785

merged 10 commits into from
Feb 5, 2023

Conversation

ayushmanchhabra
Copy link
Collaborator

@ayushmanchhabra ayushmanchhabra commented Feb 4, 2023

Fixes: #

  • Format
  • Lint
  • Test
  • Docs
  • Add name to AUTHORS (first time contributors)
  • Update CHANGELOG
  • Version bump

Description

Undocumented bug discovered through Stack Overflow. node-glob and yargs file glob seem to work differently. For now, one can tweak the glob pattern for CLI to match the required files and directories. An options.cli flag is set to true on each CLI run. This prevents node-glob from doing twice the work and erroring out with the error message as mentioned in the Stack Overflow post.

With module usage, the copied file subdir/file.js would be copied as outDir/package.nw/file.js. This is now fixed and is copied as outDir/package.nw/subdir/file.js.

@ayushmanchhabra ayushmanchhabra changed the title fix(cli): file globing fix: file globing Feb 4, 2023
@ayushmanchhabra ayushmanchhabra marked this pull request as ready for review February 5, 2023 22:11
@ayushmanchhabra ayushmanchhabra merged commit 38dc4a6 into main Feb 5, 2023
@ayushmanchhabra ayushmanchhabra deleted the fix/cli-file-glob branch February 5, 2023 22:15
log.debug(`Copy ${file} file to ${outDir} directory`);
await cp(
file,
`${outDir}/${
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/app.nw"
}/${basename(file)}`,
}/${file.split(sep).splice(2).join(sep)}`,
Copy link

@rickymohk rickymohk Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line causes problem on windows. "/" instead of sep should be used here (The rest of the path is already using "/"). file comes from glob expanded srcDir, which always use "/". split(sep) split nothing on windows causing the subdirectory to disappear.

Copy link
Collaborator Author

@ayushmanchhabra ayushmanchhabra Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you open a bug report referencing this line or a pull request to fix this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on getting Windows builds working in #795. I realise I need to use path.resolve which would remove the need for sep.

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

Successfully merging this pull request may close these issues.

2 participants