MCPcopy
hub / github.com/stenciljs/core / checkForOverwrite

Function checkForOverwrite

src/cli/task-generate.ts:194–212  ·  view source on GitHub ↗
(files: readonly BoilerplateFile[], config: ValidatedConfig)

Source from the content-addressed store, hash-verified

192 * @param config the Config object, used here to get access to `sys.readFile`
193 */
194const checkForOverwrite = async (files: readonly BoilerplateFile[], config: ValidatedConfig): Promise<void> => {
195 const alreadyPresent: string[] = [];
196
197 await Promise.all(
198 files.map(async ({ path }) => {
199 if ((await config.sys.readFile(path)) !== undefined) {
200 alreadyPresent.push(path);
201 }
202 }),
203 );
204
205 if (alreadyPresent.length > 0) {
206 config.logger.error(
207 'Generating code would overwrite the following files:',
208 ...alreadyPresent.map((path) => '\t' + normalizePath(path)),
209 );
210 await config.sys.exit(1);
211 }
212};
213
214/**
215 * Check if an extension is for a test

Callers 1

taskGenerateFunction · 0.85

Calls 5

normalizePathFunction · 0.85
readFileMethod · 0.80
pushMethod · 0.80
errorMethod · 0.80
exitMethod · 0.80

Tested by

no test coverage detected