Repository: vapor/vapor
File: Sources/Vapor/Utilities/DotEnv.swift (Swift)

Code before:
            case .shared:
                logger.trace("Running on shared EventLoopGroup. Not shutting down EventLoopGroup")
            case .createNew:
                logger.trace("Shutting down EventLoopGroup")
                do {
                    try eventLoopGroup.syncShutdownGracefully()
                } catch {
                    logger.error("Shutting down EventLoopGroup failed: \(error)")
                }
            }
        }
        
        let threadPool = NIOThreadPool(numberOfThreads: 1)
        threadPool.start()
        defer {
            do {
                try threadPool.syncShutdownGracefully()
            } catch {
                logger.error("Shutting down theadPool failed: \(error)")
            }
        }
        let fileIO = NonBlockingFileIO(threadPool: threadPool)
    
        // Load specific .env first since values are not overridden.
        let fileNames = [".env.\(environment.name)", ".env"]
        _ = fileNames.map { name in
            do {
                try load(path: name, fileio: fileIO, on: eventLoopGroup.next()).wait()
            } catch {
                logger.debug("Could not load \(name) file: \(error)")
            }
        }
    }
    
    /// Reads a dotenv file from the supplied path and loads it into the process.
    ///
    ///     let fileio: NonBlockingFileIO
    ///     let elg: EventLoopGroup
    ///     try DotEnvFile.load(path: ".env", fileio: fileio, on: elg.next()).wait()
    ///     print(Environment.process.FOO) // BAR
    ///
    /// Use `DotEnvFile.read` to read the file without loading it.
    ///
    /// - parameters:
    ///     - path: Absolute or relative path of the dotenv file.
    ///     - fileio: File loader.
    ///     - eventLoop: Eventloop to perform async work on.
    ///     - overwrite: If `true`, values already existing in the process' env
    ///                  will be overwritten. Defaults to `false`.
    public static func load(
        path: String,

Review comment (suggestion):
```suggestion
        fileNames.forEach { name in
```
That way we don't need to discard the variable and the order each load is run is more clear 👍 

Code after:
    ///     try DotEnvFile.load(path: path, on: elgp, logger: logger)
    ///     print(Environment.process.FOO) // BAR
    ///
    /// - parameters:
    ///     - path: Absolute or relative path of the dotenv file.
    ///     - eventLoopGroupProvider: Either provides an EventLoopGroup or tells the function to create a new one.
    ///     - logger: Optionally provide an existing logger.
    public static func load(
        path: String,
        on eventLoopGroupProvider: Application.EventLoopGroupProvider = .createNew,
        logger: Logger = Logger(label: "dot-env-loggger")
    ) {
        let eventLoopGroup: EventLoopGroup
        
        switch eventLoopGroupProvider {
        case .shared(let group):
            eventLoopGroup = group
        case .createNew:
            eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
        }
        defer {
            switch eventLoopGroupProvider {
            case .shared:
                logger.trace("Running on shared EventLoopGroup. Not shutting down EventLoopGroup")
            case .createNew:
                logger.trace("Shutting down EventLoopGroup")
                do {
                    try eventLoopGroup.syncShutdownGracefully()
                } catch {
                    logger.error("Shutting down EventLoopGroup failed: \(error)")
                }
            }
        }
        
        let threadPool = NIOThreadPool(numberOfThreads: 1)
        threadPool.start()
        defer {
            do {
                try threadPool.syncShutdownGracefully()
            } catch {
                logger.error("Shutting down theadPool failed: \(error)")
            }
        }
        let fileIO = NonBlockingFileIO(threadPool: threadPool)
    
        do {
            try load(path: path, fileio: fileIO, on: eventLoopGroup.next()).wait()
        } catch {
            logger.debug("Could not load \(path) file: \(error)")
        }
    }