Make WordPress Core

Changeset 59038


Ignore:
Timestamp:
09/17/2024 10:25:03 PM (3 weeks ago)
Author:
TimothyBlynJacobs
Message:

Build Tools: Allow easier customization of the .env file.

The .env file allows for configuring how the WordPress Local environment should be configured. However, because the file is version controlled, developers must be careful not to commit their modifications.

This commit renames the .env file to be .env.example. During env start, the .env.example file is copied to .env if it does not exist. This allows for contributors to continue using the project without thinking about .env and to make changes when needed. This brings WordPress Core into the dotenv project guidelines.

Props johnbillion, afragen, h71, desrosj.
Fixes #52668.

Location:
trunk
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/.gitignore

    r57640 r59038  
    22
    33# Configuration files with possibly sensitive information
     4.env
    45wp-config.php
    56wp-tests-config.php
  • trunk/tools/local-env/scripts/start.js

    r57918 r59038  
    22const dotenvExpand = require( 'dotenv-expand' );
    33const { execSync } = require( 'child_process' );
     4
     5try {
     6    execSync( 'test -f .env', { stdio: 'inherit' } );
     7} catch ( e ) {
     8    // test exits with a status code of 1 if the test fails.
     9    // Alert the user on any other failure.
     10    if ( e.status !== 1 ) {
     11        throw e;
     12    }
     13
     14    // The file does not exist, copy over the default example file.
     15    execSync( 'cp .env.example .env', { stdio: 'inherit' } );
     16}
     17
    418
    519dotenvExpand.expand( dotenv.config() );
Note: See TracChangeset for help on using the changeset viewer.