Skip to content

resolve script path duplication with relative SCRIPTFLOW_SCRIPTS_DIR#4

Open
mnikulin wants to merge 1 commit into
yanmxa:mainfrom
mnikulin:main
Open

resolve script path duplication with relative SCRIPTFLOW_SCRIPTS_DIR#4
mnikulin wants to merge 1 commit into
yanmxa:mainfrom
mnikulin:main

Conversation

@mnikulin

@mnikulin mnikulin commented Jun 27, 2026

Copy link
Copy Markdown

When SCRIPTFLOW_SCRIPTS_DIR was set to a relative path, the script path passed to the shell command already included scriptsDir, but execSync also set cwd to scriptsDir — causing the directory to be prepended twice.

Fixed by passing scriptFile directly to buildExecutionCommand instead of path.join(scriptsDir, scriptFile), since cwd is already set to scriptsDir.

Summary by Sourcery

Bug Fixes:

  • Prevent duplicate directory prefixes in script execution paths when SCRIPTFLOW_SCRIPTS_DIR is configured as a relative path.

Summary by CodeRabbit

  • Bug Fixes
    • Improved script execution handling by using the located script file directly, reducing path resolution issues.
    • Script runs continue to support metadata-based language detection, environment settings, timeouts, and consistent error reporting.

@sourcery-ai

sourcery-ai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts script execution to avoid duplicating the scripts directory in the path by passing the relative script filename to the execution command while still using scriptsDir as the working directory.

Sequence diagram for updated script execution path handling

sequenceDiagram
    participant Caller
    participant Handler as handleScriptRun
    participant Builder as buildExecutionCommand
    participant Executor as executeScript

    Caller->>Handler: handleScriptRun(args, scriptsDir, timeout, config)
    Handler->>Builder: buildExecutionCommand(scriptFile, language, scriptArgs)
    Builder-->>Handler: command
    Handler->>Executor: executeScript(command, scriptsDir, timeout, config.shellEnvironment)
    Executor-->>Handler: output
    Handler-->>Caller: { output, metadata }
Loading

File-Level Changes

Change Details Files
Fix script execution path when SCRIPTFLOW_SCRIPTS_DIR is a relative path to avoid double-prefixing the directory.
  • Stop constructing a full scriptPath with path.join(scriptsDir, scriptFile).
  • Continue computing metadataPath from scriptsDir and script name JSON file.
  • Change buildExecutionCommand call to use scriptFile directly while still executing with scriptsDir as the working directory.
src/handlers/script-run.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97ff12ea-47f4-4962-bd38-bb88473b9a69

📥 Commits

Reviewing files that changed from the base of the PR and between 357294a and 97f9490.

📒 Files selected for processing (1)
  • src/handlers/script-run.ts

📝 Walkthrough

Walkthrough

Removes the intermediate scriptPath variable in handleScriptRun that was constructed by joining scriptsDir with scriptFile. The scriptFile value from findScriptFile is now passed directly to buildExecutionCommand.

Changes

Script path simplification

Layer / File(s) Summary
Remove scriptPath, pass scriptFile directly
src/handlers/script-run.ts
Removes the path.join(scriptsDir, scriptFile) intermediate variable and passes scriptFile directly to buildExecutionCommand.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A path once joined now stands alone,
No need to build what's clearly known,
The script file hops without a detour,
Straight to the command, clean and pure,
🐇 Less code, same joy — simplicity's secure!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the path-duplication fix for relative SCRIPTFLOW_SCRIPTS_DIR values.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant