Skip to content

Instantly share code, notes, and snippets.

@jcblw
Last active October 29, 2016 22:04
Show Gist options
  • Save jcblw/fbb5981dfe1bff53dd2a to your computer and use it in GitHub Desktop.
Save jcblw/fbb5981dfe1bff53dd2a to your computer and use it in GitHub Desktop.
Gist FS

Gist FS

Gist FS is a simple interface to gist file as if writing and reading from the local file system. The way this works is that it will get some intial data using the github API and then use the push and pull to interface with the gist.

This will help make Gist programs work offline with gist data and commit things in a normal git manner. As well as allow other programs to access gist since its just a folder.

const GistFS = require('gist-fs')
const gistFS = new GistFS({baseDir: '~/.gist-fs', ..authStuff});

gistFS.readFile('b98873cfa488c6968a97/README.md', 'utf8', function(err, content){
  if (err) {
    throw err;
  }
  content += '## appended \n';
  gistFS.writeFile('b98873cfa488c6968a97/README.md', content, function(err) {
    if (err) {
      throw err;
    }
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment