Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Sep 18, 2025

Get path to root of repo from CARGO_MANIFEST_DIR env var rather than env::current_dir, so it doesn't depend on cwd.

This means that you can run cargo run -p oxc_ast_tools from anywhere in the repo, which is really useful when working on parser + linter NAPI packages which contain generated code.

The root path will also be used in another PR to follow which generates an ESTree walker.

@github-actions github-actions bot added A-ast-tools Area - AST tools C-bug Category - Bug labels Sep 18, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@overlookmotel overlookmotel marked this pull request as ready for review September 18, 2025 16:29
Copilot AI review requested due to automatic review settings September 18, 2025 16:29
Copy link
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 fixes the oxc_ast_tools to be runnable from any directory by using the CARGO_MANIFEST_DIR environment variable to determine the repository root path instead of relying on the current working directory.

  • Adds a root_path field to the Codegen struct to store the repository root path
  • Updates file path handling to use absolute paths based on the repository root
  • Passes the root path parameter through the parsing and output writing functions

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tasks/ast_tools/src/codegen.rs Adds root path calculation and storage to Codegen struct
tasks/ast_tools/src/parse/mod.rs Updates file parsing to accept and use root path parameter
tasks/ast_tools/src/parse/load.rs Modifies file loading to use root-relative paths
tasks/ast_tools/src/output/mod.rs Updates output writing to use root-relative paths
tasks/ast_tools/src/main.rs Updates calls to use the root path for file operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@overlookmotel overlookmotel self-assigned this Sep 18, 2025
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Sep 18, 2025
Copy link
Member Author

overlookmotel commented Sep 18, 2025

Merge activity

…13898)

Get path to root of repo from `CARGO_MANIFEST_DIR` env var rather than `env::current_dir`, so it doesn't depend on `cwd`.

This means that you can run `cargo run -p oxc_ast_tools` from anywhere in the repo, which is really useful when working on parser + linter NAPI packages which contain generated code.

The root path will also be used in another PR to follow which generates an ESTree walker.
@graphite-app graphite-app bot force-pushed the 09-17-fix_ast_tools_enable_oxc_ast_tools_to_be_run_from_any_directory branch from 2c96551 to 7d45b2f Compare September 18, 2025 16:31
@graphite-app graphite-app bot merged commit 7d45b2f into main Sep 18, 2025
17 checks passed
@graphite-app graphite-app bot deleted the 09-17-fix_ast_tools_enable_oxc_ast_tools_to_be_run_from_any_directory branch September 18, 2025 16:36
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants