Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Download or clone a git repository from Node.
$ npm install download-git-repo
# yarn add download-git-repo
Download a git repository
to a destination
folder with options
, and callback
.
The shorthand repository string to download the repository from:
github:owner/name
or simply owner/name
gitlab:owner/name
bitbucket:owner/name
The repository
parameter defaults to the master
branch, but you can specify a branch or tag as a URL fragment like owner/name#my-branch
.
In addition to specifying the type of where to download, you can also specify a custom origin like gitlab:custom.com:owner/name
.
Custom origin will default to https
or git@
for http and clone downloads respectively, unless protocol is specified.
Feel free to submit an issue or pull request for additional origin options.
In addition to having the shorthand for supported git hosts, you can also hit a repository directly with:
direct:url
This will bypass the shorthand normalizer and pass url
directly.
If using direct
without clone, you must pass the full url to the zip file, including paths to branches if needed.
If using direct
with clone, you must pass the full url to the git repo and you can specify a branch like direct:url#my-branch
.
The file path to download the repository to.
An optional options object parameter with download options. Options include:
clone
- boolean default false
- If true use git clone
instead of an http download. While this can be a bit slower, it does allow private repositories to be used if the appropriate SSH keys are setup.proxy
, headers
, filter
, etc.) will be passed down accordingly and may override defaults
The callback function as function (err)
.
Using http download from Github repository at master.
download("lukeocodes/download-git-repo-fixture", "test/tmp", function (err) {
console.log(err ? "Error" : "Success");
});
Using git clone from Bitbucket repository at my-branch.
download(
"bitbucket:lukeocodes/download-git-repo-fixture#my-branch",
"test/tmp",
{ clone: true },
function (err) {
console.log(err ? "Error" : "Success");
}
);
Using http download from GitLab repository with custom origin and token.
download('gitlab:mygitlab.com:lukeocodes/download-git-repo-fixture#my-branch', 'test/tmp', { headers: { 'PRIVATE-TOKEN': '1234' } } function (err) {
console.log(err ? 'Error' : 'Success')
})
Using git clone from GitLab repository with custom origin and protocol.
Note that the repository type (github
, gitlab
etc.) is not required if cloning from a custom origin.
download(
"https://mygitlab.com:lukeocodes/download-git-repo-fixture#my-branch",
"test/tmp",
{ clone: true },
function (err) {
console.log(err ? "Error" : "Success");
}
);
Using http download from direct url.
download(
"direct:https://gitlab.com/lukeocodes/download-git-repo-fixture/repository/archive.zip",
"test/tmp",
function (err) {
console.log(err ? "Error" : "Success");
}
);
Using git clone from direct url at master.
download(
"direct:https://gitlab.com/lukeocodes/download-git-repo-fixture.git",
"test/tmp",
{ clone: true },
function (err) {
console.log(err ? "Error" : "Success");
}
);
Using git clone from direct url at my-branch.
download(
"direct:https://gitlab.com/lukeocodes/download-git-repo-fixture.git#my-branch",
"test/tmp",
{ clone: true },
function (err) {
console.log(err ? "Error" : "Success");
}
);
A continuation of the effectively abandoned* package download-git-repo. Git history maintained for posterity. Questions taken as issues.
Would you like to contribute to this project? Check out our contributing guide.
Made with contrib.rocks.
FAQs
Download or clone a git repository from Node
The npm package git-a-repo receives a total of 0 weekly downloads. As such, git-a-repo popularity was classified as not popular.
We found that git-a-repo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.