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

fetchgit

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

fetchgit

Easily download files and directories from a GitHub repository.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

fetchgit

Easily download files and directories from a GitHub repository.

  • Works in Node.JS, Bun and Deno.
  • Uses fastest runtime specific APIs to write files.
  • Faster than git clone for smaller repositories.

Fetching a specific directory from a repository

Recursively fetches the directory for all the files and subdirectories inside.

import { fetchDirectory } from "fetchgit";

await fetchDirectory({
    repo: "chalk/chalk",
    path: "source/vendor/supports-color",
    destination: "./chalk"
});

Set basedir_only to true if you only want to create the directory without the parent sub-directories of path.

Fetching an entire repository

If path isn't provided, it will fetch the entire repository.

import { fetchDirectory } from "fetchgit";

await fetchDirectory({
    repo: "tr1ckydev/hyperimport",
    destination: "./hyperimport"
});

NOTE

If the repository is small (i.e. has less number of files), it can be faster than git clone in most cases but will take way too much time for larger repositories.

Fetching a single file from a repository

(Requires destination directory to be created already.)

import { fetchFile } from "fetchgit";

await fetchFile({
    repo: "oven-sh/bun",
    path: "README.md",
    branch: "main",
    destination: "./temp"
});

If branch isn't provided, the default branch name of the repository is fetched and then the file.

NOTE

Explicitly mentioning the branch name will skip the above step, making it faster to fetch the file.

License

This repository uses MIT license. See LICENSE for full license text.

Keywords

FAQs

Package last updated on 21 Feb 2024

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