@boennemann/github-change-remote-files

1.1.2 • Public • Published

github-change-remote-file

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

Note: this is a temporary hack because I needed this to work real quick. It will (? should) eventually land upstream

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 commit:

githubChangeRemoteFile({
  user: 'boennemann',
  repo: 'animals',
  filenames: ['.gitattributes', '.editorconfig']
  transforms: [function (content) {
    return createNewContent(content)
  }, function () {
    return createNewContent(content)
  }],
  token: '<github access token with sufficent rights>'
}, function (err, res) {
  console.log(res.sha) // sha of the new commit
})

Create a new commit and send a PR:

githubChangeRemoteFile({
  user: 'boennemann',
  repo: 'animals',
  filenames: ['.gitattributes', '.editorconfig']
  transforms: [function (content) {
    return createNewContent(content)
  }, function () {
    return createNewContent(content)
  }],
  token: '<github access token with sufficent rights>',
  pr: {
    title: 'Updated standard to latest version',
    body: 'whatever'
  }
}, function (err, res) {
  console.log(res.html_url) // url of the pr
})

Create a new commit and push it on top of the (master) branch:

githubChangeRemoteFile({
  user: 'boennemann',
  repo: 'animals',
  filenames: ['.gitattributes', '.editorconfig']
  transforms: [function (content) {
    return createNewContent(content)
  }, function () {
    return createNewContent(content)
  }],
  token: '<github access token with sufficent rights>',
  push: true
}, function (err, res) {
  console.log(res.object.url) // url of the new commit
})

Readme

Keywords

Package Sidebar

Install

npm i @boennemann/github-change-remote-files

Weekly Downloads

1

Version

1.1.2

License

MIT

Last publish

Collaborators

  • boennemann