You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: allow update function to trigger file deletion (#130)
BREAKING CHANGE: The meaning of `null` has changed!
Previously the following snippet was causing a file deletion.
```js
files: {
"file/to/delete.txt": null
}
```
If you want to retain this behavior you must use the DELETE_FILE Symbol
import { createPullRequest, DELETE_FILE } from 'octokit-plugin-create-pull-request';
```js
files: {
"file/to/delete.txt": DELETE_FILE
}
```
If you want to trigger a file deletion from an update function, you can now do so by returning the deleteFile Symbol.
```js
import { createPullRequest, DELETE_FILE } 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 DELETE_FILE
}
// do not alter file content
return null;
}
}
0 commit comments