Skip to content

Commit

Permalink
Update type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed May 25, 2018
1 parent 14984c6 commit 8d8aeac
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path'
import * as fsx from 'fs-extra'
import {WriteTreeObject, WriteTree} from '../../types'
import {WriteFileContent, WriteTreeObject, WriteTree} from '../../types'
import create from '../../create'

export abstract class FileSystemRepresentation {
Expand All @@ -22,7 +22,7 @@ export namespace FileSystemRepresentation {
}

export namespace File {
export type Content = string | Buffer
export type Content = WriteFileContent
}

export class Directory extends FileSystemRepresentation {
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/fs-tree-utils/lib/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {File, Directory} = FileSystemRepresentation
* @param container Where to place the tree
*/
export async function create (tree: WriteTree, container: string = ''): Promise<void> {
if (typeof tree === 'string') {
if (typeof tree === 'string' || tree instanceof Buffer) {
return create(new File(tree), container)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/fs-tree-utils/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type TreeObject = {[name: string]: TreeObject | FileContent}
export type TreeNode = FileContent | TreeObject
export type Tree = TreeNode

export type WriteFileContent = FileContent
export type WriteFileContent = FileContent | Buffer
export type WriteFunction = (name: string) => Promise<void> | void
export type WriteTreeObject = {readonly [name: string]: WriteTreeObject | WriteFileContent}
export type WriteTreeNode = WriteFileContent | WriteFunction | WriteTreeObject | FileSystemRepresentation
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/fs-tree-utils/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('create function', () => {
const secondBornFiles = {
newFileA: 'First New File',
newFileB: 'Second New File',
newFileC: 'Third New File'
newFileC: new Buffer('Third New File')
}

const firstBornFolders = {
Expand Down

0 comments on commit 8d8aeac

Please sign in to comment.