(target: string, filePath: string)
| 140 | } |
| 141 | |
| 142 | parseFile(target: string, filePath: string) { |
| 143 | const fullPath = resolveProjectPath(this.options, filePath); |
| 144 | const ext = path.extname(filePath); |
| 145 | if (!fsutils.fileExistsSync(fullPath)) { |
| 146 | throw new FirebaseError("Parse Error: Imported file " + filePath + " does not exist", { |
| 147 | exit: 1, |
| 148 | }); |
| 149 | } |
| 150 | |
| 151 | switch (ext) { |
| 152 | case ".json": |
| 153 | if (target === "database") { |
| 154 | this.notes.databaseRules = "json"; |
| 155 | } else if (target === "database.rules") { |
| 156 | this.notes.databaseRulesFile = filePath; |
| 157 | try { |
| 158 | return fs.readFileSync(fullPath, "utf8"); |
| 159 | } catch (e: any) { |
| 160 | if (e.code === "ENOENT") { |
| 161 | throw new FirebaseError(`File not found: ${fullPath}`, { original: e }); |
| 162 | } |
| 163 | throw e; |
| 164 | } |
| 165 | } |
| 166 | return loadCJSON(fullPath); |
| 167 | /* istanbul ignore-next */ |
| 168 | case ".bolt": |
| 169 | throw new FirebaseError( |
| 170 | "As of firebase-tools@15.0.0, .bolt rules are no longer supported.", |
| 171 | ); |
| 172 | default: |
| 173 | throw new FirebaseError( |
| 174 | "Parse Error: " + filePath + " is not of a supported config file type", |
| 175 | { exit: 1 }, |
| 176 | ); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | get src(): FirebaseConfig { |
| 181 | // TODO(samstern): We should do JSON Schema validation on this at load time |
no test coverage detected