smartfile/ts/smartfile.classes.smartfile.ts

77 lines
1.2 KiB
TypeScript
Raw Normal View History

import * as plugins from './smartfile.plugins'
export interface ISmartfileConstructorOptions {
path?: string
contentsString?: string
contentBuffer?: Buffer
}
2016-09-20 15:56:49 +00:00
2017-04-27 14:48:08 +00:00
/**
* class Smartfile
* -> is vinyl file compatible
*/
export class Smartfile {
2017-04-27 14:48:08 +00:00
/**
* the full path of the file on disk
*/
path: string
2017-04-27 14:48:08 +00:00
/**
* The contents of the file as Buffer
*/
contents: Buffer
2017-04-27 14:48:08 +00:00
/**
* The current working directory of the file
*/
cwd: string
/**
* sync the file with disk
*/
sync: boolean
/**
* the constructor of Smartfile
* @param optionsArg
*/
constructor (optionsArg: ISmartfileConstructorOptions) {
if (optionsArg.contentBuffer) {
this.contents = optionsArg.contentBuffer
2017-04-27 14:48:08 +00:00
} else if (optionsArg.contentsString) {
this.contents = new Buffer(optionsArg.contentsString)
2016-09-20 15:56:49 +00:00
}
this.path = optionsArg.path
}
2017-04-27 14:48:08 +00:00
/**
* return relative path of file
* ->
*/
get relative () {
return ''
}
/**
* set contents from string
* @param contentString
*/
2017-04-27 14:48:08 +00:00
setContentsFromString(contentString: string) {
this.contents = new Buffer(contentString)
}
2017-04-27 14:48:08 +00:00
/**
* write file to disk
*/
async write () {
}
/**
* read file from disk
*/
async read () {
}
2016-09-20 15:56:49 +00:00
}