Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,3 @@ LOCAL_SCRIPT_DEBUG=true
LOCAL_WP_ENVIRONMENT_TYPE=local
LOCAL_WP_DEVELOPMENT_MODE=core
LOCAL_WP_TESTS_DOMAIN=example.org

##
# This silences the tips output by the dotenv package.
##
DOTENV_CONFIG_QUIET=true
31 changes: 0 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
"@wordpress/prettier-config": "4.51.0",
"@wordpress/scripts": "33.0.0",
"autoprefixer": "10.5.3",
"dotenv": "17.4.2",
"dotenv-expand": "13.0.0",
"grunt": "1.6.2",
"grunt-banner": "^0.6.0",
"grunt-contrib-clean": "~2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/wp-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function wpCli( args, options = {} ) {
{
encoding: 'utf-8',
...options,
env: { ...process.env, ...options.env, DOTENV_CONFIG_QUIET: 'true' },
env: { ...process.env, ...options.env },
}
);
}
4 changes: 1 addition & 3 deletions tools/local-env/scripts/docker.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* jshint node:true */

const dotenv = require( 'dotenv' );
const dotenvExpand = require( 'dotenv-expand' );
const local_env_utils = require( './utils' );

local_env_utils.ensure_env_file();

dotenvExpand.expand( dotenv.config() );
local_env_utils.load_env();

// Use Xdebug to generate HTML code coverage reports, unless PCOV is enabled and Xdebug is not.
if (
Expand Down
4 changes: 1 addition & 3 deletions tools/local-env/scripts/install.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/* jshint node:true */

const dotenv = require( 'dotenv' );
const dotenvExpand = require( 'dotenv-expand' );
const wait_on = require( 'wait-on' );
const { execSync } = require( 'child_process' );
const { readFileSync, writeFileSync } = require( 'fs' );
const local_env_utils = require( './utils' );

local_env_utils.ensure_env_file();

dotenvExpand.expand( dotenv.config() );
local_env_utils.load_env();

// Create wp-config.php. This verifies the database connection, so retrying it keeps
// `env:install` working on its own, without `env:start` having waited for the mysql
Expand Down
4 changes: 1 addition & 3 deletions tools/local-env/scripts/start.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/* jshint node:true */

const dotenv = require( 'dotenv' );
const dotenvExpand = require( 'dotenv-expand' );
const { execSync, spawnSync } = require( 'child_process' );
const local_env_utils = require( './utils' );

local_env_utils.ensure_env_file();

dotenvExpand.expand( dotenv.config() );
local_env_utils.load_env();

// Check if the Docker service is running.
try {
Expand Down
20 changes: 20 additions & 0 deletions tools/local-env/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ const local_env_utils = {
}
},

/**
* Loads the settings in .env into `process.env`.
*
* Variables that are already set in the environment take precedence over the values in .env.
* Values are not expanded: Docker Compose expands `${VAR}` references itself when it reads .env.
*/
load_env: function() {
try {
process.loadEnvFile( join( repo_root, '.env' ) );
} catch ( e ) {
/*
* The script should still run when the .env file is missing, falling back to the defined
* default values. Missing .env files are already detected and noted by ensure_env_file().
*/
if ( e.code !== 'ENOENT' ) {
console.warn( `Could not load the .env file. ${ e.message }` );
}
}
},

/**
* Runs a Docker Compose command, re-attempting it when it fails.
*
Expand Down
Loading