fix Smartfile class

This commit is contained in:
2017-04-29 17:20:09 +02:00
parent 7457093476
commit 32cdac5b38
3 changed files with 25 additions and 9 deletions

View File

@ -2,7 +2,7 @@ import * as plugins from './smartfile.plugins'
export interface ISmartfileConstructorOptions {
path?: string
contentsString?: string
contentString?: string
contentBuffer?: Buffer
}
@ -17,10 +17,15 @@ export class Smartfile {
path: string
/**
* The contents of the file as Buffer
* gulp-compatibility: alias of this.contentBuffer
*/
contents: Buffer
/**
* the content of the file as Buffer
*/
contentBuffer: Buffer
/**
* The current working directory of the file
*/
@ -37,9 +42,12 @@ export class Smartfile {
*/
constructor (optionsArg: ISmartfileConstructorOptions) {
if (optionsArg.contentBuffer) {
this.contentBuffer = optionsArg.contentBuffer
this.contents = optionsArg.contentBuffer
} else if (optionsArg.contentsString) {
this.contents = new Buffer(optionsArg.contentsString)
} else if (optionsArg.contentString) {
this.contents = Buffer.from(optionsArg.contentString)
} else {
console.log('created empty Smartfile?')
}
this.path = optionsArg.path
}