MCPcopy Create free account
hub / github.com/code-pushup/cli / patchRootGitLabConfig

Function patchRootGitLabConfig

packages/create-cli/src/lib/setup/ci.ts:119–142  ·  view source on GitHub ↗
(tree: Tree)

Source from the content-addressed store, hash-verified

117}
118
119async function patchRootGitLabConfig(tree: Tree): Promise<void> {
120 const content = await tree.read(GITLAB_CONFIG_PATH);
121 if (content == null) {
122 return;
123 }
124 const doc = YAML.parseDocument(content);
125 if (!YAML.isMap(doc.contents)) {
126 logger.warn(
127 `Could not update ${GITLAB_CONFIG_PATH}. Add an include entry for ${GITLAB_CONFIG_SEPARATE_PATH} to your config.`,
128 );
129 return;
130 }
131 const entry = { local: GITLAB_CONFIG_SEPARATE_PATH };
132 const include = doc.get('include', true);
133 if (include == null) {
134 doc.set('include', doc.createNode([entry]));
135 } else if (YAML.isSeq(include)) {
136 include.add(doc.createNode(entry));
137 } else {
138 const existing = doc.get('include');
139 doc.set('include', doc.createNode([existing, entry]));
140 }
141 await tree.write(GITLAB_CONFIG_PATH, doc.toString());
142}
143
144async function resolveGitLabFilePath(tree: Tree): Promise<string> {
145 if (await tree.exists(GITLAB_CONFIG_PATH)) {

Callers 1

writeGitLabConfigFunction · 0.85

Calls 2

warnMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected