MCPcopy Create free account
hub / github.com/EndBug/label-sync / readConfigFile

Function readConfigFile

src/index.ts:130–157  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

128}
129
130function readConfigFile(filePath: string) {
131 startGroup('Reading config file...')
132 let file: string
133
134 try {
135 // Read the file from the given path
136 log.info('Reading file...')
137
138 const resolvedPath = path.resolve(filePath)
139 core.debug(`Resolved path: ${resolvedPath}`)
140
141 file = fs.readFileSync(resolvedPath, { encoding: 'utf-8' })
142 core.debug(`fs ok: type ${typeof file}`)
143 core.debug(file)
144
145 if (!file || typeof file != 'string') throw null
146 } catch (e) {
147 core.debug(`Actual error: ${e}`)
148 throw "Can't access config file."
149 }
150
151 const parsed = parseConfigFile(path.extname(filePath).toLowerCase(), file)
152
153 log.success('File parsed successfully.')
154 log.info('Parsed config:\n' + JSON.stringify(parsed, null, 2))
155 endGroup()
156 return parsed
157}
158
159function parseConfigFile(
160 fileExtension: string,

Callers 1

index.tsFile · 0.85

Calls 1

parseConfigFileFunction · 0.85

Tested by

no test coverage detected