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

build changes cwd #1186

Closed
1 of 3 tasks
breavyn opened this issue Aug 4, 2024 · 3 comments · Fixed by #1187 or #1178
Closed
1 of 3 tasks

build changes cwd #1186

breavyn opened this issue Aug 4, 2024 · 3 comments · Fixed by #1187 or #1178

Comments

@breavyn
Copy link
Contributor

breavyn commented Aug 4, 2024

Issue Type

  • Bug Report
  • Feature Request
  • Other

Current/Missing Behaviour

Calling nwbuild with mode: "build" and manageManifest will change the processes cwd to use the package manager. This requires the caller to save and restore the cwd when using nwbuild.

process.chdir(

A similar issue exists here also.

const buildNativeAddon = ({ cacheDir, version, platform, arch, outDir, nodeVersion }) => {

Expected/Proposed Behaviour

The package manager should be executed with the needed cwd, without changing the calling processes cwd.

I can submit a PR if desired.

@ayushmanchhabra
Copy link
Collaborator

ayushmanchhabra commented Aug 4, 2024

@breavyn PR would be great. But before that would like to understand how this is a bug? How does saving and restoring the cwd lead to buggy behaviour with respect to the built application?

@breavyn
Copy link
Contributor Author

breavyn commented Aug 4, 2024

The nwjs application itself is built correctly. However, silently changing the cwd is hostile to users trying to call nwbuild from a script. It causes any further filesystem related operations to have unintended outcomes.

I propose either not changing the cwd in the first place, which is a trivial change. Or clearly documenting that this is intended behaviour, suggesting the user save and restore the cwd themselves if needed.

const cwd = process.cwd();
await nwbuild({...});
process.chdir(cwd);

Keeping in mind changing this behaviour would break scripts relying on the cwd change.

@ayushmanchhabra
Copy link
Collaborator

@breavyn I understand now, please go ahead with the pull request.

Keeping in mind changing this behaviour would break scripts relying on the cwd change.

I think as long as the application builds correctly in managed manifest mode, it should be fine.

ayushmanchhabra pushed a commit that referenced this issue Aug 5, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.8.1](v4.8.0...v4.8.1)
(2024-08-05)


### Bug Fixes

* **bld:** maintain cwd when using managedManifest or nativeAddon
([#1187](#1187))
([40223db](40223db)),
closes [#1186](#1186)


### Chores

* **deps:** bump the npm group across 1 directory with 6 updates
([#1185](#1185))
([f4c0822](f4c0822))
* **deps:** remove unused cli-progress package
([8f4e07d](8f4e07d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants