From 221ff62068f5d91a155abc28c09e8f9c507aa15b Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 9 Oct 2024 14:54:11 -0400 Subject: [PATCH] Use `node:fs` for copying files. --- tools/local-env/scripts/start.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tools/local-env/scripts/start.js b/tools/local-env/scripts/start.js index 22bb65ca8426d..88c803fee8b0d 100644 --- a/tools/local-env/scripts/start.js +++ b/tools/local-env/scripts/start.js @@ -1,20 +1,11 @@ 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' } ); -} - +copyFile( '.env.example', '.env', constants.COPYFILE_EXCL, (e) => { + console.log( 'An .env file already exists.' ); +}); dotenvExpand.expand( dotenv.config() );