Skip to content

boennemann/github-change-remote-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-change-remote-file

Build Status Coverage Status Dependency Status devDependency Status js-standard-style

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)