summaryrefslogtreecommitdiffstatshomepage
path: root/tools/local-env
diff options
context:
space:
mode:
authorJonathan Desrosiers <desrosj@git.wordpress.org>2024-10-18 12:35:37 +0000
committerJonathan Desrosiers <desrosj@git.wordpress.org>2024-10-18 12:35:37 +0000
commit0dd8843c31d87299c237d833733affffb731fbf9 (patch)
tree2eeb5180a18eb64e1f38df0e860cea165696b79e /tools/local-env
parent6bb92c17e1acceec7a04c57f3c5d10cb1677b2e8 (diff)
downloadwordpress-0dd8843c31d87299c237d833733affffb731fbf9.tar.gz
wordpress-0dd8843c31d87299c237d833733affffb731fbf9.zip
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59249 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'tools/local-env')
-rw-r--r--tools/local-env/scripts/start.js18
1 files changed, 5 insertions, 13 deletions
diff --git a/tools/local-env/scripts/start.js b/tools/local-env/scripts/start.js
index 22bb65ca84..92fa360149 100644
--- a/tools/local-env/scripts/start.js
+++ b/tools/local-env/scripts/start.js
@@ -1,20 +1,12 @@
const dotenv = require( 'dotenv' );
const dotenvExpand = require( 'dotenv-expand' );
const { execSync } = require( 'child_process' );
+const { constants, copyFile } = require( 'node:fs' );
-try {
- execSync( 'test -f .env', { stdio: 'inherit' } );
-} catch ( e ) {
- // test exits with a status code of 1 if the test fails.
- // Alert the user on any other failure.
- if ( e.status !== 1 ) {
- throw e;
- }
-
- // The file does not exist, copy over the default example file.
- execSync( 'cp .env.example .env', { stdio: 'inherit' } );
-}
-
+// Copy the default .env file when one is not present.
+copyFile( '.env.example', '.env', constants.COPYFILE_EXCL, (e) => {
+ console.log( '.env file already exists. .env.example was not copied.' );
+});
dotenvExpand.expand( dotenv.config() );