MCPcopy Index your code
hub / github.com/changesets/changesets / readPreState

Function readPreState

packages/pre/src/index.ts:10–32  ·  view source on GitHub ↗
(
  rootDir: string
)

Source from the content-addressed store, hash-verified

8} from "@changesets/errors";
9
10export 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
34export async function exitPre(rootDir: string) {
35 let preStatePath = path.resolve(rootDir, ".changeset", "pre.json");

Callers 7

getReleasePlanFunction · 0.90
versionFunction · 0.90
publishFunction · 0.90
index.test.tsFile · 0.90
readChangesetStateFunction · 0.90
exitPreFunction · 0.85
enterPreFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected