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

Function getCommitFunctions

packages/cli/src/commit/getCommitFunctions.ts:5–35  ·  view source on GitHub ↗
(
  commit: false | readonly [string, any],
  cwd: string
)

Source from the content-addressed store, hash-verified

3import resolveFrom from "resolve-from";
4
5export async function getCommitFunctions(
6 commit: false | readonly [string, any],
7 cwd: string
8): Promise<[CommitFunctions, any]> {
9 let commitFunctions: CommitFunctions = {};
10 if (!commit) {
11 return [commitFunctions, null];
12 }
13 let commitOpts: any = commit[1];
14 let changesetPath = path.join(cwd, ".changeset");
15 let commitPath = resolveFrom(changesetPath, commit[0]);
16
17 let possibleCommitFunc = await import(commitPath);
18 if (possibleCommitFunc.default) {
19 possibleCommitFunc = possibleCommitFunc.default;
20
21 // Check nested default again in case it's CJS with `__esModule` interop
22 if (possibleCommitFunc.default) {
23 possibleCommitFunc = possibleCommitFunc.default;
24 }
25 }
26 if (
27 typeof possibleCommitFunc.getAddMessage === "function" ||
28 typeof possibleCommitFunc.getVersionMessage === "function"
29 ) {
30 commitFunctions = possibleCommitFunc;
31 } else {
32 throw new Error("Could not resolve commit generation functions");
33 }
34 return [commitFunctions, commitOpts];
35}

Callers 2

versionFunction · 0.90
addFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected