Make WordPress Core

Changeset 59249


Ignore:
Timestamp:
10/18/2024 12:35:37 PM (7 months ago)
Author:
desrosj
Message:

Build/Test Tools: Change commands used for the copying .env.example file.

This switches from using the test/cp commands when copying the .env.example file to using node:fs. test and cp are not available on Windows machines.

This also adds the .env file to the svn:ignore list to prevent it from being committed accidentally.

Follow up to [59038].

Props afercia, Clorith, poena.
Fixes #52668.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1818# Files for local environment config
        1919/docker-compose.override.yml
         20.env
  • trunk/tools/local-env/scripts/start.js

    r59038 r59249  
    22const dotenvExpand = require( 'dotenv-expand' );
    33const { execSync } = require( 'child_process' );
     4const { constants, copyFile } = require( 'node:fs' );
    45
    5 try {
    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 
     6// Copy the default .env file when one is not present.
     7copyFile( '.env.example', '.env', constants.COPYFILE_EXCL, (e) => {
     8    console.log( '.env file already exists. .env.example was not copied.' );
     9});
    1810
    1911dotenvExpand.expand( dotenv.config() );
Note: See TracChangeset for help on using the changeset viewer.