()
| 127 | |
| 128 | |
| 129 | export async function getNetlifyConfigPath () { |
| 130 | const searchDirectories = new Set() |
| 131 | |
| 132 | // Local dev usually runs from repo root, but deployed serverless |
| 133 | // functions may execute from a nested working directory. |
| 134 | for ( const baseDirectory of [ |
| 135 | process.cwd(), |
| 136 | currentModuleDirectory, |
| 137 | ] ) { |
| 138 | let directory = baseDirectory |
| 139 | |
| 140 | while ( true ) { |
| 141 | searchDirectories.add( directory ) |
| 142 | |
| 143 | const parentDirectory = path.dirname( directory ) |
| 144 | |
| 145 | if ( parentDirectory === directory ) break |
| 146 | |
| 147 | directory = parentDirectory |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | for ( const directory of searchDirectories ) { |
| 152 | const configPath = path.join( directory, 'netlify.toml' ) |
| 153 | |
| 154 | if ( await fs.pathExists( configPath ) ) { |
| 155 | return configPath |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | throw new Error( 'Could not find netlify.toml' ) |
| 160 | } |
| 161 | |
| 162 | export async function getNetlifyConfig () { |
| 163 | const configPath = await getNetlifyConfigPath() |
no outgoing calls
no test coverage detected