Skip to content

Commit

Permalink
fix(source-file): should support writing strings to files
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Sep 15, 2021
1 parent cf49788 commit 632170a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/source-file/src/file.fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export class FsFile implements FileSystem<SourceFile> {
return this.head(filePath).then((f) => f != null);
}

async write(filePath: string, buf: Buffer | Readable): Promise<void> {
async write(filePath: string, buf: Buffer | Readable | string): Promise<void> {
const folderPath = path.dirname(filePath);
await fs.promises.mkdir(folderPath, { recursive: true });
try {
if (Buffer.isBuffer(buf)) {
if (Buffer.isBuffer(buf) || typeof buf === 'string') {
await fs.promises.writeFile(filePath, buf);
} else {
const st = fs.createWriteStream(filePath);
Expand Down

0 comments on commit 632170a

Please sign in to comment.