(tree: Tree)
| 117 | } |
| 118 | |
| 119 | async 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 | |
| 144 | async function resolveGitLabFilePath(tree: Tree): Promise<string> { |
| 145 | if (await tree.exists(GITLAB_CONFIG_PATH)) { |
no test coverage detected