(file, realm, family)
| 181 | } |
| 182 | |
| 183 | async function scaffoldRealm(file, realm, family) { |
| 184 | const addition = await builderSource(realm, family); |
| 185 | if (!(await exists(file))) { |
| 186 | await mkdir(dirname(file), { recursive: true }); |
| 187 | await writeFile(file, addition); |
| 188 | return "created"; |
| 189 | } |
| 190 | |
| 191 | const source = await readFile(file, "utf8"); |
| 192 | if (new RegExp(`export\\s+function\\s+${family}\\b`).test(source)) { |
| 193 | return "already exports this family"; |
| 194 | } |
| 195 | await writeFile(file, `${source.trimEnd()}\n\n${addition}`); |
| 196 | return "added family"; |
| 197 | } |
| 198 | |
| 199 | async function scaffoldOverride(file, realm, family) { |
| 200 | if (await exists(file)) return "already exists"; |
no test coverage detected