MCPcopy
hub / github.com/ThatGuySam/doesitarm / getNetlifyConfigPath

Function getNetlifyConfigPath

helpers/config-node.js:129–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

127
128
129export 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
162export async function getNetlifyConfig () {
163 const configPath = await getNetlifyConfigPath()

Callers 2

getNetlifyConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected