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

Allow programmatic file deletion #129

Closed
stefanbuck opened this issue May 15, 2023 · 2 comments · Fixed by #130
Closed

Allow programmatic file deletion #129

stefanbuck opened this issue May 15, 2023 · 2 comments · Fixed by #130
Labels

Comments

@stefanbuck
Copy link
Contributor

stefanbuck commented May 15, 2023

The current API design supports just a single way of deleting a file

files: {
  "file/to/delete.txt"" null
}

However, it would be useful to trigger a file deletion based on specific conditions, such as the example below:

files: {
  "file/to/delete.txt": ({ exists, encoding, content }) => {
    // do not create the file if it does not exist
    if (!exists) return null;

    const fileContent = Buffer.from(content, encoding).toString("utf-8")

    if (fileContent.includes('abc')) {
      // trigger file deletion
      return ???
    }

    // do not alter file content
    return null;
  }
}

Since both null and undefined already have different functionalities, it is unclear what return value could be used to instruct the library to initiate a file deletion. What are your thoughts?

@gr2m
Copy link
Owner

gr2m commented May 16, 2023

Since both null and undefined already have different functionalities, it is unclear what return value could be used to instruct the library to initiate a file deletion. What are your thoughts?

I think the correct way to do this is to use Symbols. See how mapObjectSkip is implemented in map-obj. I don't mind releasing a breaking change for this.

What do you think?

@github-actions
Copy link

github-actions bot commented Jun 4, 2023

🎉 This issue has been resolved in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants