[Feature Request] Infer the test environment from the command varlock run launches
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- bun, node.js, typescript
Research direction
Start at the varlock run command entry point and trace how it resolves VARLOCK_ENV before launching child processes; the issue does not name a source file or test. Check the existing tests for command parsing and environment precedence, then add coverage for the listed runners and bunx/npx forms. Done means recognized test commands select test only when no explicit environment or @currentEnv value overrides it.
Written by the indexing model from the issue text.
Description
Description
When varlock run launches a test runner, infer the test environment from the command itself, so VARLOCK_ENV is test without passing a flag.
Motivation
The Bun guide now recommends varlock run -- bun test. But varlock run resolves before the runner starts, and it's the runner that sets NODE_ENV=test, so VARLOCK_ENV comes out as development. Repro on 1.21.0:
# @defaultSensitive=false
# ---
ENV_NAME=$VARLOCK_ENV
// x.test.ts
import { test } from "bun:test";
test("env", () => console.log("ENV_NAME =", process.env.ENV_NAME, "NODE_ENV =", process.env.NODE_ENV));
varlock run -- bun test prints ENV_NAME = development NODE_ENV = test.
The builtin variables docs cover this and recommend passing the flag explicitly (VARLOCK_ENV=test varlock run -- vitest), so every test script in every package of a monorepo carries it. Forgetting it on one package runs its tests against development config without any error.
Proposed Solution
In varlock run, when VARLOCK_ENV is not already set, look at the command being run: bun test, vitest, jest, node --test, mocha (and the same through bunx/npx) resolve with VARLOCK_ENV=test. An explicit VARLOCK_ENV or @currentEnv value still wins. It could be an opt-in root decorator if guessing from argv is too implicit.
Alternatives
- Pass the flag in every test script (what the docs recommend today).
- A
varlock test -- <cmd>shorthand that sets the test environment.
Additional Information
The same timing problem applies to anything that sets its own NODE_ENV after startup, but test runners are by far the common case.
- Dominant language
- TypeScript
- Stars
- 4.9k
- Forks
- 140
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 35
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dmno-dev/varlock
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
dmno-dev/varlock#1279 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
dmno-dev/varlock#1100 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
dmno-dev/varlock#1278 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
dmno-dev/varlock#1275 · 1 comment ·
Maintainers usually reply within 1 day
-
core:varlock RFC
Difficulty 5/5 Over a week Newbie friendliness 28/100
dmno-dev/varlock#1258 · 1 comment ·
Maintainers usually reply within 1 day
All issues in dmno-dev/varlock
Similar issues
-
documentation good first issue roadmap
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
resend/react-email#3876 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
siyuan-note/siyuan#21324 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
himynameisdave/bsky-profanity-counter#59 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100