Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github-watchify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-watchify

Polls a github repo and returns a list of any changed files. Think of it as a post-commit webhook for repos you don't own.

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Github-Watchify

Github-watchify is a node module that will poll a github repo and notify you of any changed files. Think of it as a post-commit webhook for repos you don't own.

Installation

npm install --save github-watchify

##Authentication The library requires the use of personal access tokens for github because it completely removes the need for github passwords to be stored, even in environment vars. Learn more about creating personal access tokens here.

Usage

First things first, require the module and create a new instance. When creating a watcher, you'll have to supply a user agent string, which github requires for all API calls, as well as the token mentioned in the Authentication section.

const Watchify = require('./github-watchify');

const watcher = new Watchify({
    userAgent: 'github-watchify', //unique user agent string required by github
    token: 'A_KEWL_GITHUB_TOKEN'
});

Then we can have some fun. Here I'm polling http://github.com/elifitch/test-repo for changes every 10 seconds. There's an onPing function that executes every time the watcher checks the repo for any new commits and supplies the latest commit sha as an argument. The fun happens in the onCommit function which executes every time the watcher detects a new commit. The function provides a commit comparison, as well as a list of all the files that were changed in the commit.

watcher.watch({
  targetUser: 'elifitch',
  targetRepo: 'test-repo',
  interval: 10000,
  onCommit: function(commit, changedFiles) {
    console.log(changedFiles);
  },
  onPing: function(commitSha) {
    console.log(commitSha);
  }
});

#Party Time ᕕ( ᐛ )ᕗ

FAQs

Package last updated on 13 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc