Skip to content

Commit

Permalink
feat: #666 - Calling Project#createSourceFile with an existing file…
Browse files Browse the repository at this point in the history
… name now suggests to add the overwrite option.
  • Loading branch information
dsherret committed Sep 1, 2019
1 parent c929c6c commit 3022bb8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/factories/CompilerFactory.ts
Expand Up @@ -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<typeof options>);
this.throwIfFileExists(filePath);
this.throwIfFileExists(filePath, "Did you mean to provide the overwrite option?");
return this.createSourceFileFromTextInternal(filePath, sourceText, options as MakeOptionalUndefined<typeof options>);
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests/projectTests.ts
Expand Up @@ -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", () => {
Expand Down

0 comments on commit 3022bb8

Please sign in to comment.