From 3022bb82664ffa88b24d308f9cbf85d1dcbe66f3 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 1 Sep 2019 10:16:04 -0400 Subject: [PATCH] feat: #666 - Calling `Project#createSourceFile` with an existing file name now suggests to add the overwrite option. --- src/factories/CompilerFactory.ts | 2 +- src/tests/projectTests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/factories/CompilerFactory.ts b/src/factories/CompilerFactory.ts index 66895c352..78f78dba7 100644 --- a/src/factories/CompilerFactory.ts +++ b/src/factories/CompilerFactory.ts @@ -148,7 +148,7 @@ export class CompilerFactory { filePath = this.context.fileSystemWrapper.getStandardizedAbsolutePath(filePath); if (options.overwrite === true) return this.createOrOverwriteSourceFileFromText(filePath, sourceText, options as MakeOptionalUndefined); - this.throwIfFileExists(filePath); + this.throwIfFileExists(filePath, "Did you mean to provide the overwrite option?"); return this.createSourceFileFromTextInternal(filePath, sourceText, options as MakeOptionalUndefined); } diff --git a/src/tests/projectTests.ts b/src/tests/projectTests.ts index 9c0fa187a..25eaa1381 100644 --- a/src/tests/projectTests.ts +++ b/src/tests/projectTests.ts @@ -751,7 +751,7 @@ describe(nameof(Project), () => { project.createSourceFile("file.ts", ""); expect(() => { project.createSourceFile("file.ts", ""); - }).to.throw(errors.InvalidOperationError, `A source file already exists at the provided file path: /file.ts`); + }).to.throw(errors.InvalidOperationError, `Did you mean to provide the overwrite option? A source file already exists at the provided file path: /file.ts`); }); it("should not throw an exception if creating a source file at an existing path when providing the overwrite option", () => {