Skip to content

Commit

Permalink
refactor: Remove getEmitSkipped() from DirectoryEmitResult because it…
Browse files Browse the repository at this point in the history
… was not accurate.

BREAKING CHANGE: `DirectoryEmitResult#getEmitSkipped()` was removed. Check the output file paths and skipped file paths instead as that's more accurate.
  • Loading branch information
dsherret committed Aug 31, 2019
1 parent e3db1db commit f42ff74
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 20 deletions.
5 changes: 0 additions & 5 deletions lib/ts-morph.d.ts
Expand Up @@ -288,11 +288,6 @@ export declare class DirectoryEmitResult {
private readonly _skippedFilePaths;
private readonly _outputFilePaths;
private constructor();
/**
* Gets if the emit was skipped.
* @deprecated This is being deprecated in favour of getSkippedFilePaths().
*/
getEmitSkipped(): boolean;
/**
* Gets a collections of skipped file paths.
*/
Expand Down
10 changes: 1 addition & 9 deletions src/fileSystem/DirectoryEmitResult.ts
@@ -1,16 +1,8 @@
export class DirectoryEmitResult {
export class DirectoryEmitResult {
/** @private */
constructor(private readonly _skippedFilePaths: ReadonlyArray<string>, private readonly _outputFilePaths: ReadonlyArray<string>) {
}

/**
* Gets if the emit was skipped.
* @deprecated This is being deprecated in favour of getSkippedFilePaths().
*/
getEmitSkipped() {
return this._skippedFilePaths.length > 0;
}

/** Gets a collections of skipped file paths. */
getSkippedFilePaths() {
return this._skippedFilePaths as string[];
Expand Down
2 changes: 1 addition & 1 deletion src/next-major-deprecations.md
@@ -1,6 +1,6 @@
# Deprecations in the next major

* Remove DirectoryEmitResult#getSkippedFilePaths()
* None

# Future version

Expand Down
5 changes: 0 additions & 5 deletions src/tests/fileSystem/directoryTests.ts
Expand Up @@ -1539,7 +1539,6 @@ describe(nameof(Directory), () => {
function runChecks(fileSystem: FileSystemHost & CustomFileSystemProps, result: DirectoryEmitResult, outDir: string, declarationDir: string) {
const writeLog = fileSystem.getWriteLog();

expect(result.getEmitSkipped()).to.be.false;
expect(result.getOutputFilePaths().sort()).to.deep.equal(writeLog.map(l => l.filePath).sort());
expect(writeLog.map(l => l.filePath).sort()).to.deep.equal([
outDir + "/file1.js.map",
Expand Down Expand Up @@ -1599,7 +1598,6 @@ describe(nameof(Directory), () => {
subDir.createSourceFile("file1.ts", "export class Parent extends Child {}");
subDir.createSourceFile("file2.ts", "");
const result = await directory.emit();
expect(result.getEmitSkipped()).to.be.true;
expect(result.getSkippedFilePaths()).to.deep.equal(["/dir/sub/file1.ts"]);

const writeLog = fileSystem.getWriteLog();
Expand All @@ -1625,7 +1623,6 @@ describe(nameof(Directory), () => {
function runChecks(fileSystem: FileSystemHost & CustomFileSystemProps, result: DirectoryEmitResult, outDir: string, declarationDir: string) {
const writeLog = fileSystem.getWriteLog();

expect(result.getEmitSkipped()).to.be.false;
expect(result.getOutputFilePaths()).to.deep.equal(writeLog.map(l => l.filePath));
expect(writeLog[0].filePath).to.equal(outDir + "/file1.js.map");
expect(writeLog[1].filePath).to.equal(outDir + "/file1.js");
Expand All @@ -1651,7 +1648,6 @@ describe(nameof(Directory), () => {
const subDir2 = directory.createDirectory("sub2");
subDir.createSourceFile("file1.ts", "");
const result = subDir.emitSync({ outDir: "../sub2" });
expect(result.getEmitSkipped()).to.be.false;

const writeLog = fileSystem.getWriteLog();
expect(result.getOutputFilePaths()).to.deep.equal(writeLog.map(l => l.filePath));
Expand All @@ -1667,7 +1663,6 @@ describe(nameof(Directory), () => {
subDir.createSourceFile("file1.ts", "export class Parent extends Child {}");
subDir.createSourceFile("file2.ts", "");
const result = directory.emitSync();
expect(result.getEmitSkipped()).to.be.true;
expect(result.getSkippedFilePaths()).to.deep.equal(["/dir/sub/file1.ts"]);

const writeLog = fileSystem.getWriteLog();
Expand Down

0 comments on commit f42ff74

Please sign in to comment.