Skip to content

Commit

Permalink
fix(fs): fs.source should never return null
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Sep 16, 2021
1 parent 3564902 commit 4c22b84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ export interface FileSystem<T extends ChunkSource = ChunkSource> {
/** Get information about the path */
head(filePath: string): Promise<FileInfo | null>;
/** Create a file source to read chunks out of */
source(filePath: string): T | null;
source(filePath: string): T;
}
6 changes: 4 additions & 2 deletions packages/source-aws/src/s3.fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ export class FsAwsS3 implements FileSystem<SourceAwsS3> {
constructor(s3: S3Like) {
this.s3 = s3;
}
source(filePath: string): SourceAwsS3 | null {
return SourceAwsS3.fromUri(filePath, this.s3);
source(filePath: string): SourceAwsS3 {
const source = SourceAwsS3.fromUri(filePath, this.s3);
if (source == null) throw new Error(`Failed to create aws s3 source from uri: ${filePath}`);
return source;
}

/** Is this file system a s3 file system */
Expand Down
2 changes: 1 addition & 1 deletion packages/source-file/src/file.fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class FsFile implements FileSystem<SourceFile> {
return fs.protocol === FsFile.protocol;
}

source(filePath: string): SourceFile | null {
source(filePath: string): SourceFile {
return new SourceFile(filePath);
}

Expand Down

0 comments on commit 4c22b84

Please sign in to comment.