fix(core): update
This commit is contained in:
@ -133,12 +133,10 @@ export class Smartfile extends plugins.smartjson.Smartjson {
|
||||
}
|
||||
|
||||
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);
|
||||
dirPathArg = plugins.smartpath.transform.toAbsolute(dirPathArg);
|
||||
const filePath = plugins.path.join(dirPathArg, this.path);
|
||||
await memory.toFs(this.contentBuffer, filePath);
|
||||
return filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,16 +24,16 @@ export class VirtualDirectory {
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
private fileArray: Smartfile[] = [];
|
||||
public smartfileArray: Smartfile[] = [];
|
||||
|
||||
constructor() {}
|
||||
|
||||
public addSmartfiles(smartfileArrayArg: Smartfile[]) {
|
||||
this.fileArray = this.fileArray.concat(smartfileArrayArg);
|
||||
this.smartfileArray = this.smartfileArray.concat(smartfileArrayArg);
|
||||
}
|
||||
|
||||
public async getFileByPath(pathArg: string) {
|
||||
for (const smartfile of this.fileArray) {
|
||||
for (const smartfile of this.smartfileArray) {
|
||||
if (smartfile.path === pathArg) {
|
||||
return smartfile;
|
||||
}
|
||||
@ -42,13 +42,17 @@ export class VirtualDirectory {
|
||||
|
||||
public async toVirtualDirTransferableObject(): Promise<plugins.smartfileInterfaces.VirtualDirTransferableObject> {
|
||||
return {
|
||||
files: this.fileArray.map(smartfileArg => smartfileArg.foldToJson())
|
||||
files: this.smartfileArray.map(smartfileArg => smartfileArg.foldToJson())
|
||||
};
|
||||
}
|
||||
|
||||
public async saveToDisk() {
|
||||
for (const smartfileArg of this.fileArray) {
|
||||
|
||||
public async saveToDisk(dirArg: string) {
|
||||
console.log(`writing VirtualDirectory with ${this.smartfileArray.length} to directory:
|
||||
--> ${dirArg}`);
|
||||
for (const smartfileArg of this.smartfileArray) {
|
||||
const filePath = await smartfileArg.writeToDir(dirArg);
|
||||
console.log(`wrote ${smartfileArg.relative} to
|
||||
--> ${filePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ export const fileTreeToObject = async (dirPathArg: string, miniMatchFilter: stri
|
||||
if (plugins.path.isAbsolute(miniMatchFilter)) {
|
||||
dirPath = '/';
|
||||
} else {
|
||||
dirPath = dirPathArg;
|
||||
dirPath = plugins.smartpath.transform.toAbsolute(dirPathArg);
|
||||
}
|
||||
|
||||
const fileTree = await listFileTree(dirPath, miniMatchFilter);
|
||||
|
Reference in New Issue
Block a user