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

feat: allow update function to trigger file deletion #130

Merged
merged 1 commit into from Jun 4, 2023

Commits on Jun 4, 2023

  1. feat: allow update function to trigger file deletion

    BREAKING CHANGE: The meaning of `null` has changed!
    
    Previously the following snippet was causing a file deletion.
    
    files: {
      "file/to/delete.txt": null
    }
    
    If you want to remain this behavior you must use the deleteFile Symbol
    
    import { createPullRequest, deleteFile } from 'octokit-plugin-create-pull-request';
    
    files: {
      "file/to/delete.txt": deleteFile
    }
    
    If you want to trigger a file deletion from an update function, you can now do so by returning  the deleteFile Symbol.
    
    import { createPullRequest, deleteFile } from 'octokit-plugin-create-pull-request';
    
    files: {
      "file/to/delete.txt": ({ exists, encoding, content }) => {
        const fileContent = Buffer.from(content, encoding).toString("utf-8")
    
        if (fileContent.includes('abc')) {
          // trigger file deletion
          return deleteFile
        }
    
        // do not alter file content
        return null;
      }
    }
    stefanbuck committed Jun 4, 2023
    Copy the full SHA
    a22d8e8 View commit details
    Browse the repository at this point in the history