fix(core): update

This commit is contained in:
2023-07-08 16:24:53 +02:00
parent 3c1eb1ab70
commit 2fc37d6892
4 changed files with 82 additions and 59 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartfile',
version: '10.0.25',
version: '10.0.26',
description: 'offers smart ways to work with files in nodejs'
}

View File

@ -47,7 +47,7 @@ export class VirtualDirectory {
}
public async saveToDisk(dirArg: string) {
console.log(`writing VirtualDirectory with ${this.smartfileArray.length} to directory:
console.log(`writing VirtualDirectory with ${this.smartfileArray.length} files to directory:
--> ${dirArg}`);
for (const smartfileArg of this.smartfileArray) {
const filePath = await smartfileArg.writeToDir(dirArg);
@ -56,6 +56,22 @@ export class VirtualDirectory {
}
}
// TODO implement root shifting to get subdirectories as new virtual directories
// TODO implement root shifting to combine VirtualDirecotries in a parent virtual directory
public async shiftToSubdirectory(subDir: string): Promise<VirtualDirectory> {
const newVirtualDir = new VirtualDirectory();
for (const file of this.smartfileArray) {
if (file.path.startsWith(subDir)) {
const adjustedFilePath = plugins.path.relative(subDir, file.path);
file.path = adjustedFilePath;
newVirtualDir.addSmartfiles([file]);
}
}
return newVirtualDir;
}
public async addVirtualDirectory(virtualDir: VirtualDirectory, newRoot: string): Promise<void> {
for (const file of virtualDir.smartfileArray) {
file.path = plugins.path.join(newRoot, file.path);
}
this.addSmartfiles(virtualDir.smartfileArray);
}
}