mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5835] [MERGED] fix(cli): strip module prefix before script execution #5373
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5373
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5835
Author: @jamesgeorge007
Created: 2/4/2026
Status: ✅ Merged
Merged: 2/5/2026
Merged by: @jamesgeorge007
Base:
patch← Head:fix/cli-strip-module-prefix📝 Commits (1)
ee3ec78fix(cli): strip module prefix before script execution📊 Changes
4 files changed (+72 additions, -49 deletions)
View changed files
📝
packages/hoppscotch-cli/src/__tests__/e2e/fixtures/collections/scripting-revamp-coll.json(+4 -4)📝
packages/hoppscotch-cli/src/utils/mutators.ts(+16 -0)📝
packages/hoppscotch-cli/src/utils/pre-request.ts(+50 -44)📝
packages/hoppscotch-cli/src/utils/test.ts(+2 -1)📄 Description
Closes #5834, FE-1127.
Scripts saved from the web app include an
export {};\nprefix added by the Monaco editor for TypeScript IntelliSense. The CLI was not stripping this prefix before execution, causing test scripts to fail withSyntaxError: Unexpected token 'export'when running collections from workspaces via PAT. While exporting collections, it was stripped off and hence didn't affect the scenario with supplying the collection file path.CLI counterpart to #5555.
What's changed
stripModulePrefixutility to strip the module prefix before sandbox execution.Notes to reviewers
Try creating a request with a variable in the post-request script under a collection and a sample test case. Run the collection from the pre-existing version of the CLI by supplying the collection ID & PAT, and observe the failure similar to the attached issue. Repeat the same with the CLI changes in scope here and observe a successful run.
This can also be validated with the scripting-revamp-collection from the test fixtures.
Summary by cubic
Fixes CLI script execution by stripping the Monaco-added module prefix (export {};), preventing “Unexpected token 'export'” errors when running collections via PAT. Scripts saved from the app now run correctly in the CLI.
Written for commit
ee3ec78125. Summary will update on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.