fix(core): update
This commit is contained in:
@ -136,6 +136,11 @@ export class Smartfile extends plugins.smartjson.Smartjson {
|
||||
await memory.toFs(this.contentBuffer, filePathArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* writes the file to a directory combined with the relative path portion
|
||||
* @param dirPathArg
|
||||
* @returns
|
||||
*/
|
||||
public async writeToDir(dirPathArg: string) {
|
||||
dirPathArg = plugins.smartpath.transform.toAbsolute(dirPathArg);
|
||||
const filePath = plugins.path.join(dirPathArg, this.path);
|
||||
@ -146,7 +151,16 @@ export class Smartfile extends plugins.smartjson.Smartjson {
|
||||
/**
|
||||
* read file from disk
|
||||
*/
|
||||
public async read() {}
|
||||
public async read() {
|
||||
this.contentBuffer = await fs.toBuffer(this.path);
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes the file from disk at its original location
|
||||
*/
|
||||
public async delete() {
|
||||
await fs.remove(this.path);
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
// vinyl compatibility
|
||||
|
@ -202,6 +202,10 @@ export const toStringSync = (filePath: string): string => {
|
||||
return fileString;
|
||||
};
|
||||
|
||||
export const toBuffer = async (filePath: string): Promise<Buffer> => {
|
||||
return plugins.fsExtra.readFile(filePath);
|
||||
};
|
||||
|
||||
export const toBufferSync = (filePath: string): Buffer => {
|
||||
return plugins.fsExtra.readFileSync(filePath);
|
||||
};
|
||||
|
Reference in New Issue
Block a user