Make WordPress Core

Changeset 63422


Ignore:
Timestamp:
09/01/2026 05:50:10 PM (11 hours ago)
Author:
lancewillett
Message:

Build/Test Tools: Correct local environment failure handling.

Merges [62871] and [63416] to the 7.0 branch.

Developed in: https://github.com/WordPress/wordpress-develop/pull/13352

Reviewed by: johnbillion.
Props jonsurrell, lucasbustamante, mukesh27, adrianmoldovanwp.
See #65745.

Location:
branches/7.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/7.0

  • branches/7.0/tools/local-env/scripts/docker.js

    r61196 r63422  
    3939);
    4040
    41 process.exit( returns.status );
     41if ( returns.error ) {
     42        console.error( `Could not run Docker Compose. ${ returns.error.message }` );
     43} else if ( returns.signal && returns.signal !== 'SIGINT' ) {
     44        console.error( `Docker Compose was terminated by ${ returns.signal }.` );
     45}
     46
     47// `status` is null when Docker could not be spawned at all, or was killed by a signal. SIGINT is
     48// how a long-running command such as `env:logs` is normally ended, so it is not a failure worth an
     49// npm error block. Every other signal means the command was killed before it finished.
     50process.exit( returns.signal === 'SIGINT' ? 0 : ( returns.status ?? 1 ) );
  • branches/7.0/tools/local-env/scripts/start.js

    r61459 r63422  
    55const { execSync, spawnSync } = require( 'child_process' );
    66const local_env_utils = require( './utils' );
    7 const { constants, copyFile } = require( 'node:fs' );
     7const { copyFileSync, existsSync } = require( 'node:fs' );
    88
    99// Copy the default .env file when one is not present.
    10 copyFile( '.env.example', '.env', constants.COPYFILE_EXCL, () => {
    11         console.log( '.env file already exists. .env.example was not copied.' );
    12 });
     10if ( ! existsSync( '.env' ) ) {
     11        copyFileSync( '.env.example', '.env' );
     12}
    1313
    1414dotenvExpand.expand( dotenv.config() );
     
    3333}
    3434
    35 spawnSync(
     35const up = spawnSync(
    3636        'docker',
    3737        [
     
    4545        { stdio: 'inherit' }
    4646);
     47
     48// No signal is exempt here, unlike in `docker.js`: `env:start` runs `composer update -W` next, and
     49// that must not run against containers that never came up.
     50if ( up.status !== 0 ) {
     51        const reason = up.signal ? `It was terminated by ${ up.signal }.` : up.error?.message ?? '';
     52
     53        console.error( `Could not start the Docker containers. ${ reason }`.trim() );
     54
     55        // `status` is null when Docker could not be spawned at all, or was killed by a signal.
     56        process.exit( up.status ?? 1 );
     57}
    4758
    4859// If Docker Toolbox is being used, we need to manually forward LOCAL_PORT to the Docker VM.
Note: See TracChangeset for help on using the changeset viewer.