2.1.0 • Published 10 months ago
pub-src-github v2.1.0
pub-src-github
GitHub source for pub-server and pub-generator
- provides
get()
andput()
for bulk reads and writes - works in conjunction with
pub-src-fs/fs-base
- assumes that all files with non-binary extensions are utf-8 text
- globs and descends directories
src(options)
var src = require('pub-src-github');
// instantiate source
// options become properties of source
var source = src(
{ repo:'jldec/date-plus',
branch:'main',
path:'/',
glob:'*.md' } );
source.get(function(err, files) {
if (err) return console.log(err);
console.log(_.pluck(files, 'path'));
});
source.repo, .branch
repo
is requiredbranch
will default to 'main' (breaking change as of pub-src-github v2.0.0)
source.username, .password
username
andpassword
may be required to access private repos
source.path
- defaults to '/'
source.glob
glob
is a node-glob pattern
source.depth
depth
limits the depth of directory descent when source.glob includes**/
(globstar)
source.writeOnly
- disables reading with .get()
source.get(cb)
get()
fetches all matching files in one async operation- the result is an array of file objects each with a
path:
and atext:
property (for non-binary files), or abuffer:
property (for binary files) - the array is sorted alphabetically by path
- results do not include directories, but do include files in subdirectories
- if the source is writable,
get()
is atomic with respect toput()
or othersource.get()
operations
[ { path: '/README.md',
text: '...' } ]
source.put(files, options, cb)
- does nothing unless
writable
is set on the source - commits an array of file objects in a single commit
- is atomic with respect to
source.get()
or othersource.put()
operations - returns an array of the paths written
source.put(
files,
{commitMsg: 'hello'},
function(err, result) {
if (err) return console.log(err);
console.log(result);
}
);
configuring access to a github repo
- github provides account settings, under "Applications" to create "Personal access tokens"
- this is just a string which can be used in the API and behaves like a password
- to configure repo access for pub-src-github, set the following variables in your environment
export GH={your-access-token}
export GH_REPO={your-repo}
tests/test-get
can read this module's github repo, buttests/test-put
requires an access token to write to the repo- in order to run
npm test
yourself, first generate your own personal access token, and run the tests against your fork
2.1.0
10 months ago
2.0.1
2 years ago
2.0.0
3 years ago
1.3.14
5 years ago
1.3.13
5 years ago
1.3.12
5 years ago
1.3.11
5 years ago
1.3.10
5 years ago
1.3.9
6 years ago
1.3.8
6 years ago
1.3.7
6 years ago
1.3.6
6 years ago
1.3.5
6 years ago
1.3.4
6 years ago
1.3.3
6 years ago
1.3.2
6 years ago
1.3.1
6 years ago
1.3.0
10 years ago
1.2.9
10 years ago
1.2.8
10 years ago
1.2.7
10 years ago
1.2.6
10 years ago
1.2.5
10 years ago
1.2.4
10 years ago
1.2.3
10 years ago
1.2.2
10 years ago
1.2.1
10 years ago
1.2.0
10 years ago
1.1.2
10 years ago
1.1.1
10 years ago
1.1.0
10 years ago
1.0.0
10 years ago
0.5.1
10 years ago
0.5.0
10 years ago