github-change-remote-file
v4.2.0
Published
create a new commit with a changed file
Downloads
6
Readme
github-change-remote-file
| | | | | | | --- | --- | --- | --- | --- |
This module allows you to change a single file in a repository on GitHub and create a new commit or pull-request from that change. This has little to no overhead, because it doesn't work with a local copy of the git repository – everything is done via the GitHub API.
Examples
Create a new branch and commit on top of it:
githubChangeRemoteFile({
user: 'boennemann',
repo: 'animals',
filename: 'package.json',
newBranch: 'upgrade-standard',
transform: pkg => {
const parsedPkg = JSON.parse(pkg)
pkg.devDependencies.standard = semver.inc(parsedPkg.devDependencies.standard, 'major')
return JSON.stringify(parsedPkg, null, 2)
},
token: '<github access token with sufficent rights>'
})
.then(res => console.log(res))
.catch(console.log)
Create a new commit and push it on top of the (master) branch:
githubChangeRemoteFile({
user: 'boennemann',
repo: 'animals',
filename: 'package.json',
transform: pkg => {
const parsedPkg = JSON.parse(pkg)
pkg.devDependencies.standard = semver.inc(parsedPkg.devDependencies.standard, 'major')
return JSON.stringify(parsedPkg, null, 2)
},
token: '<github access token with sufficent rights>'
})
.then(res => console.log(res))
.catch(console.log)