Repository navigation
Conversation
The local Docker environment scripts only need the values in `.env` that they
read themselves. Node.js can load a `.env` file natively with
`process.loadEnvFile()`, available since Node.js 20.12, so the `dotenv` and
`dotenv-expand` packages are no longer needed.
Values are no longer expanded. Docker Compose expands `${VAR}` references
itself when it reads `.env`, and the only reference in `.env.example`
(`WP_BASE_URL`) is not read by these scripts.
This also avoids `dotenv-expand` 1000.0.0, which adds command substitution
during expansion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Y86gwpKRNgXhhtQMbSgQW
…I helper. The `wpCli()` helper set this so the tips printed by the `dotenv` package did not end up in the WP-CLI output it captures. The local environment scripts now load `.env` with `process.loadEnvFile()`, which prints nothing, so the variable no longer does anything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
…ve-loadenvfile # Conflicts: # .env.example
…`load_env()`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
The local Docker environment scripts (
env:start,env:install,env:cli, and the rest that go throughdocker.js) useddotenvanddotenv-expandto read.envintoprocess.env. Node.js can do this itself withprocess.loadEnvFile(), and the minimum Node.js version (24.18) supports it, so both packages are removed.This also avoids
dotenv-expand1000.0.0, which adds command substitution during expansion.This adds a
load_env()helper that the local environment scripts now use. It also removes two lines from.env.examplethat nothing reads anymore,WP_BASE_URLandDOTENV_CONFIG_QUIET, and stops settingDOTENV_CONFIG_QUIETin the E2EwpCli()helper.Behavior
.env.process.loadEnvFile()copies each value intoprocess.envas written, so a reference such as${PHP_VERSION}stays literal. No value in.env.exampleuses a reference..envis silent, becauseensure_env_file()already reports it. Any other read error prints a warning and the command keeps running, asensure_env_file()does.DOTENV_CONFIG_QUIET=trueline in an existing.envdoes nothing.Known issue
An existing
.envthat uses references breaks. For example:load_env()exportsLOCAL_PHPas the literal${PHP_VERSION}-fpm, and everydocker composecommand inherits it. Compose gives variables in the environment precedence over.env, so it uses the literal value instead of expanding the line itself. The image becomeswordpressdevelop/php:${PHP_VERSION}-fpm. A reference inLOCAL_PORT, such as${PORT_BASE:-88}89, makes Compose fail withinvalid IP address. A fix is being worked out before this PR leaves draft.Testing
.envgives the expected values (LOCAL_PORT=8889,LOCAL_DIR=src, …).LOCAL_PORT=9999in the shell overrides the value in.env..envproduces no output. An unreadable.envprints the warning and the script keeps running.jshintpasses ontools/local-env/scripts/.npm ls dotenv dotenv-expandis empty.AI Usage
This patch was written with Claude Code and reviewed by me.
🤖 Generated with Claude Code