Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 884 Bytes

README.md

File metadata and controls

22 lines (19 loc) · 884 Bytes

git-clone-client

No dependency, no file-system Git shallow clone client for Node.js

import { shallowCloneRef, httpFetchUsing } from 'git-clone-client';

async function handleRequest(req, res) {
    const files = await shallowCloneRef('refs/heads/main', {
        // Provide fetching method
        makeRequest: fetchRepository('https://github.com/probeiuscorp/git-clone-client.git'),
        // Partial clone -- only fetch files in the src/ directory
        filter: (filepath) => filepath.startsWith('src/'),
    });
}
// Use conveniently provided HTTP util, in this case with your environment's fetch method.
// Write your own to request over git://, ssh:// or whatever!
const fetchRepository = httpFetchUsing(fetch);

Note

This package uses node:zlib, node:crypto and node:buffer. To use different packages, fork and change imports of src/git-objects.ts.