fix(core): update

This commit is contained in:
Philipp Kunz 2020-10-09 15:15:47 +00:00
parent 53e595a023
commit e2c3005a08
3 changed files with 33 additions and 9 deletions

View File

@ -113,13 +113,32 @@ export class Smartfile extends plugins.smartjson.Smartjson {
} }
/** /**
* write file to disk * write file to disk at its original location
* Behaviours: * Behaviours:
* - no argument write to exactly where the file was picked up * - no argument write to exactly where the file was picked up
*/ */
public async write(pathArg?: string) { public async write() {
const stringToWrite = this.contentBuffer.toString(); await memory.toFs(this.contentBuffer, this.path);
await memory.toFs(stringToWrite, this.path); }
/**
* writes the file to path given as argument
* @param filePathArg
*/
public async writeToDiskAtPath(filePathArg: string) {
if (!plugins.path.isAbsolute(filePathArg)) {
filePathArg = plugins.path.join(process.cwd(), filePathArg);
}
await memory.toFs(this.contentBuffer, filePathArg);
}
public async writeToDir(dirPathArg: string) {
if (!plugins.path.isAbsolute(dirPathArg)) {
dirPathArg = plugins.path.join(process.cwd(), dirPathArg);
}
const relativePath = this.relative;
const filePath = plugins.path.join(dirPathArg, relativePath);
await memory.toFs(this.contentBuffer, filePath);
} }
/** /**

View File

@ -46,6 +46,12 @@ export class VirtualDirectory {
}; };
} }
public async saveToDisk() {
for (const smartfileArg of this.fileArray) {
}
}
// TODO implement root shifting to get subdirectories as new virtual directories // TODO implement root shifting to get subdirectories as new virtual directories
// TODO implement root shifting to combine VirtualDirecotries in a parent virtual directory // TODO implement root shifting to combine VirtualDirecotries in a parent virtual directory
} }

View File

@ -1,8 +1,7 @@
import plugins = require('./smartfile.plugins'); import * as plugins from './smartfile.plugins';
import { Smartfile } from './smartfile.classes.smartfile'; import { Smartfile } from './smartfile.classes.smartfile';
import * as smartfileFs from './smartfile.fs'; import * as smartfileFs from './smartfile.fs';
import * as interpreter from './smartfile.interpreter';
import SmartfileInterpreter = require('./smartfile.interpreter');
/** /**
* converts file to Object * converts file to Object
@ -10,8 +9,8 @@ import SmartfileInterpreter = require('./smartfile.interpreter');
* @param fileTypeArg * @param fileTypeArg
* @returns {any|any} * @returns {any|any}
*/ */
export let toObject = function (fileStringArg: string, fileTypeArg: string) { export let toObject = (fileStringArg: string, fileTypeArg: string) => {
return SmartfileInterpreter.objectFile(fileStringArg, fileTypeArg); return interpreter.objectFile(fileStringArg, fileTypeArg);
}; };
export interface IToFsOptions { export interface IToFsOptions {