(filePath: string)
| 128 | } |
| 129 | |
| 130 | function 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 | |
| 159 | function parseConfigFile( |
| 160 | fileExtension: string, |
no test coverage detected