Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@neodx/vfs Implement Layers API #148

Open
secundant opened this issue Jun 26, 2024 · 0 comments
Open

@neodx/vfs Implement Layers API #148

secundant opened this issue Jun 26, 2024 · 0 comments
Assignees
Labels
scope:vfs Issues related to vfs

Comments

@secundant
Copy link
Owner

The current implementation of @neodx/vfs relies on granular change tracking, which works well in typical cases.
However, I've found that this approach has significant limitations and lacks the potential for future growth.
For instance, the following scenarios are blocked:

  • Symbolic links support due to its chaining nature and our lack of it.
  • Cleaning up parent directories with future writes underneath them due to the lack of a steps concept.

Illustration of the real issue (from the docs)

Unfortunately, the following code will not work as expected:

async function reinitWorkingDir(vfs: Vfs) {
  // 1. Cleanup working dir
  await vfs.delete('.');
  // 2. Write some initial files
  await vfs.write('index.ts', `export const foo = 'bar';`);
}

Instead of the deletion of the working directory, our current implementation will "forget" about it because of child file writes.

We plan to fix this in the nearest future.
Currently, you can use the following workarounds:

// Variant A - scan and delete all files directly
async function reinitWorkingDir(vfs: Vfs) {
  // 1. Delete all files and directories
  await concurrently(await vfs.glob('**/*'), vfs.delete);
  // 2. Write some initial files
  await vfs.write('index.ts', `export const foo = 'bar';`);
}

// Variant B - use `apply` method right after the deletion
async function reinitWorkingDir(vfs: Vfs) {
  // 1. Cleanup working dir
  await vfs.delete('.');
  await vfs.apply();
  // 2. Write some initial files
  await vfs.write('index.ts', `export const foo = 'bar';`);
}
@secundant secundant self-assigned this Jun 26, 2024
@secundant secundant added the scope:vfs Issues related to vfs label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:vfs Issues related to vfs
Projects
None yet
Development

No branches or pull requests

1 participant