@@ -259,28 +259,31 @@ export function addDevEnvVariables() {
259259 devPath = path . resolve ( devPath . trim ( ) ) ;
260260
261261 // Check if the path exists and is a directory
262- if ( ! fs . existsSync ( devPath ) ) {
263- logger . error ( `DEV_USER_EXTENSIONS_PATH does not exist: ${ devPath } . Removing from environment.` ) ;
264- delete process . env . DEV_USER_EXTENSIONS_PATH ;
265- } else {
266- try {
267- const stats = fs . statSync ( devPath ) ;
268- if ( ! stats . isDirectory ( ) ) {
269- logger . error ( `DEV_USER_EXTENSIONS_PATH is not a directory: ${ devPath } . Removing from environment.` ) ;
270- delete process . env . DEV_USER_EXTENSIONS_PATH ;
271- } else {
272- // Update the environment variable with the sanitized (trimmed and resolved) path
273- process . env . DEV_USER_EXTENSIONS_PATH = devPath ;
274- }
275- } catch ( error ) {
276- const nodeError = error as NodeJS . ErrnoException ;
277- const errorCode = nodeError . code || "UNKNOWN" ;
278- const errorMessage = errorCode === "EACCES"
279- ? `Permission denied accessing DEV_USER_EXTENSIONS_PATH: ${ devPath } . Removing from environment.`
280- : `Error accessing DEV_USER_EXTENSIONS_PATH: ${ devPath } (${ errorCode } ). Removing from environment.` ;
281- logger . error ( errorMessage , error as Error ) ;
262+ try {
263+ const stats = fs . statSync ( devPath ) ;
264+ if ( ! stats . isDirectory ( ) ) {
265+ logger . error ( `DEV_USER_EXTENSIONS_PATH is not a directory: ${ devPath } . Removing from environment.` ) ;
282266 delete process . env . DEV_USER_EXTENSIONS_PATH ;
267+ } else {
268+ // Update the environment variable with the sanitized (trimmed and resolved) path
269+ process . env . DEV_USER_EXTENSIONS_PATH = devPath ;
283270 }
271+ } catch ( error ) {
272+ const nodeError = error as NodeJS . ErrnoException ;
273+ const errorCode = nodeError . code || "UNKNOWN" ;
274+
275+ // Provide specific error messages based on the error code
276+ let errorMessage : string ;
277+ if ( errorCode === "ENOENT" ) {
278+ errorMessage = `DEV_USER_EXTENSIONS_PATH does not exist: ${ devPath } . Removing from environment.` ;
279+ } else if ( errorCode === "EACCES" ) {
280+ errorMessage = `Permission denied accessing DEV_USER_EXTENSIONS_PATH: ${ devPath } . Removing from environment.` ;
281+ } else {
282+ errorMessage = `Error accessing DEV_USER_EXTENSIONS_PATH: ${ devPath } (${ errorCode } ). Removing from environment.` ;
283+ }
284+
285+ logger . error ( errorMessage , error as Error ) ;
286+ delete process . env . DEV_USER_EXTENSIONS_PATH ;
284287 }
285288 }
286289}
0 commit comments