MCPcopy
hub / github.com/prisma/prisma / readConfig

Function readConfig

packages/cli/src/utils/nps/survey.ts:164–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

162}
163
164async function readConfig(): Promise<NpsConfig | undefined> {
165 const data = await fs.promises
166 .readFile(getConfigPath(), 'utf-8')
167 .catch((err) => (err.code === 'ENOENT' ? Promise.resolve(undefined) : Promise.reject(err)))
168 if (data === undefined) {
169 return undefined
170 }
171
172 const obj = JSON.parse(data)
173 if (
174 obj.acknowledgedTimeframe &&
175 typeof obj.acknowledgedTimeframe.start === 'string' &&
176 typeof obj.acknowledgedTimeframe.end === 'string'
177 ) {
178 return obj
179 } else {
180 throw new Error('Invalid NPS config schema')
181 }
182}
183
184async function writeConfig(config: NpsConfig) {
185 const configPath = getConfigPath()

Callers 1

handleNpsSurveyImplFunction · 0.85

Calls 3

getConfigPathFunction · 0.85
catchMethod · 0.80
parseMethod · 0.65

Tested by

no test coverage detected