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

gist-sync

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gist-sync

a lib to help sync a directory to your gist

  • 0.2.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Gist Sync

This is a lib that allows you to sync a directory to you github gist.

Concept

This makes and updates one file gists. Add a file to your synced directory and it makes a gist. Edit a file in that directory and it updates that gist.

Usage

npm install gist-sync
import GistSync from 'gist-sync'

GistsSync.of('/Users/foo/example-path', {
  applicationToken: 'foobarqux', // a personal access token from github
  isWatching: true, // auto start watch
  setCache: (name, content) => Promise.resolve(), // set cache
  clearCache: () => Promise.resolve(), // set cache
  getCache: (name) => Promise.resolve('my-cache') // set cache
})

or the alternative new syntax

new GistSync(dir, options)
Cache

You need to pass setCache, clearCache, and getCache to the options. This allows the program to have some persistence of data. You can use just about anything for storage. Event just memory :D. The functions allow for async operations. All you need to do is return a Promise. This is the case for all three methods. Eg.

...
getCache (key) {
  return new Promise((resolve, reject) => {
    db.lookup(key, (err, resp) => {
      if (err) return reject(err)
      resolve(resp)
    })
  })
}  
...
Methods

pauseWatcher will stop the watcher from watching the directory for file changes. This will then stop syncing the files

gistSync.pauseWatcher()

resumeWatcher will resume the watcher to watch the directory for file changes. This will then start syncing the files.

If you dont pass true to isWatching you will not sync files till calling resumeWatcher

gistSync.resumeWatcher()

Contributing

Just one run npm test before making a PR.

Roadmap

  • Some type of polling for changes that are pushed to github and updating file cache
  • turn into a binary and all for command line usage
  • ideas? make a issue

FAQs

Package last updated on 28 Oct 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