( rootDir: string )
| 8 | } from "@changesets/errors"; |
| 9 | |
| 10 | export async function readPreState( |
| 11 | rootDir: string |
| 12 | ): Promise<PreState | undefined> { |
| 13 | let preStatePath = path.resolve(rootDir, ".changeset", "pre.json"); |
| 14 | // TODO: verify that the pre state isn't broken |
| 15 | let preState: PreState | undefined; |
| 16 | try { |
| 17 | let contents = await fs.readFile(preStatePath, "utf8"); |
| 18 | try { |
| 19 | preState = JSON.parse(contents); |
| 20 | } catch (err) { |
| 21 | if (err instanceof SyntaxError) { |
| 22 | console.error("error parsing json:", contents); |
| 23 | } |
| 24 | throw err; |
| 25 | } |
| 26 | } catch (err) { |
| 27 | if ((err as any).code !== "ENOENT") { |
| 28 | throw err; |
| 29 | } |
| 30 | } |
| 31 | return preState; |
| 32 | } |
| 33 | |
| 34 | export async function exitPre(rootDir: string) { |
| 35 | let preStatePath = path.resolve(rootDir, ".changeset", "pre.json"); |
no outgoing calls
no test coverage detected