2017-03-04 20:10:46 +00:00
|
|
|
import * as plugins from './smartfile.plugins'
|
|
|
|
|
|
|
|
export interface ISmartfileConstructorOptions {
|
|
|
|
path?: string
|
|
|
|
contentsString?: string
|
|
|
|
contentBuffer?: Buffer
|
|
|
|
}
|
2016-09-20 15:56:49 +00:00
|
|
|
|
2017-03-04 20:10:46 +00:00
|
|
|
export class Smartfile {
|
|
|
|
path: string
|
|
|
|
contents: Buffer
|
|
|
|
constructor(optionsArg: ISmartfileConstructorOptions) {
|
|
|
|
if (optionsArg.contentBuffer) {
|
|
|
|
this.contents = optionsArg.contentBuffer
|
|
|
|
} else if(optionsArg.contentsString) {
|
|
|
|
this.contents = new Buffer(optionsArg.contentsString)
|
2016-09-20 15:56:49 +00:00
|
|
|
}
|
2017-03-04 20:10:46 +00:00
|
|
|
this.path = optionsArg.path
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set contents from string
|
|
|
|
* @param contentString
|
|
|
|
*/
|
|
|
|
setContentFromString(contentString: string) {
|
|
|
|
this.contents = new Buffer(contentString)
|
|
|
|
}
|
2016-09-20 15:56:49 +00:00
|
|
|
}
|