Skip to content

no-bug: A few quality-of-life tweaks, take 2#13637

Open
iskunk wants to merge 1 commit into
zen-browser:devfrom
iskunk:pr-iskunk
Open

no-bug: A few quality-of-life tweaks, take 2#13637
iskunk wants to merge 1 commit into
zen-browser:devfrom
iskunk:pr-iskunk

Conversation

@iskunk
Copy link
Copy Markdown
Contributor

@iskunk iskunk commented May 10, 2026

This should support npm run import on Windows. I looked into run-script-os, and a couple other approaches, but then figured it would be simpler to just call a small Python script that looks up the environment variable and calls cargo/$CARGO as appropriate.

Please give this a try, and let me know if you see any regressions.


package.json: Invoke cargo(1) through a Python script that honors the CARGO environment variable if set, and pass arguments to ffprefs using the new convention (see below)

run_cargo.py: Script to invoke cargo(1), as a workaround for reading an environment variable in a package.json script in a cross-platform manner

update_service_dumps.py: Allow specifying DUMPS_FOLDER and ENGINE_DUMPS_FOLDER on the command line

ffprefs/src/main.rs: Allow specifying the prefs and engine dirs on the command line instead of hard-coding their locations relative to a common root dir

@iskunk iskunk requested a review from mr-cheffy as a code owner May 10, 2026 06:09
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. Improvement labels May 10, 2026
@mr-cheffy mr-cheffy requested a review from Copilot May 10, 2026 07:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make npm run import more cross-platform (notably on Windows) by avoiding direct cargo invocation from package.json, and by making path inputs configurable for the supporting import scripts/tools.

Changes:

  • Updated npm run ffprefs to invoke Cargo via a small Python wrapper that honors the CARGO environment variable.
  • Updated ffprefs to accept explicit prefs and engine paths (instead of relying on a shared root + chdir).
  • Added optional CLI overrides for dump folder paths in update_service_dumps.py.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tools/ffprefs/src/main.rs Switches ffprefs from chdir-based root handling to explicit prefs/engine path arguments.
scripts/update_service_dumps.py Adds optional argv-based overrides for dumps folder locations.
scripts/run_cargo.py Introduces a Python wrapper to execute Cargo, honoring $CARGO when set.
package.json Uses run_cargo.py for ffprefs and passes prefs/engine args using the new convention.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/ffprefs/src/main.rs
Comment on lines 340 to +356
fn main() {
let args: Vec<String> = env::args().collect();
let root_path = if args.len() > 1 {
let prefs_path = if args.len() > 1 {
PathBuf::from(&args[1])
} else {
env::current_dir().expect("Failed to get current directory")
PathBuf::from("prefs")
};
let engine_path = if args.len() > 2 {
PathBuf::from(&args[2])
} else {
PathBuf::from("engine")
};
env::set_current_dir(&root_path).expect("Failed to change directory");

prepare_zen_prefs();
let mut preferences = load_preferences();
prepare_zen_prefs(&engine_path);
let mut preferences = load_preferences(&prefs_path);
expand_pref_values(&mut preferences);
write_preferences(&preferences);
write_preferences(&engine_path, &preferences);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Zen build tooling already works with $CWD/.surfer/.

Comment thread scripts/run_cargo.py Outdated
Comment on lines +14 to +15
except Exception:
print('Exec failed', file=sys.stderr)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've pushed an update that makes the error message more informative.

Comment on lines +64 to 66
if len(sys.argv) == 3:
_, DUMPS_FOLDER, ENGINE_DUMPS_FOLDER = sys.argv
main()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

update_service_dumps.py is not a general-purpose utility that needs extensive input validation and usage information. My goal here was a minimal change that allows the locations to be specified externally.

package.json: Invoke cargo(1) through a Python script that honors the
CARGO environment variable if set, and pass arguments to ffprefs using
the new convention (see below)

run_cargo.py: Script to invoke cargo(1), as a workaround for reading
an environment variable in a package.json script in a cross-platform
manner

update_service_dumps.py: Allow specifying DUMPS_FOLDER and
ENGINE_DUMPS_FOLDER on the command line

ffprefs/src/main.rs: Allow specifying the prefs and engine dirs on
the command line instead of hard-coding their locations relative to
a common root dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants