Download directory from a GitHub repo
npm install dgh> ⬇️ Download directory from a GitHub repo.

``bash`
npm install dgh
`js
import dgh from "dgh";
dgh({
owner: "lencx",
repo: "download-github",
name: "test-dgh",
ref: "main", // default HEADtrue
overwrite: true, // default process.cwd()
root: "./", // default `
});
`js
/ repo subdir & file overwrite /
import dgh from "dgh";
dgh({
owner: "lencx",
repo: "download-github",
name: "test-dgh",
ref: "HEAD", // github branch, default 'HEAD'
subdir: "src",
})
.on("info", (msg) => {
console.log(msg);
})
.on("overwrite", (files, fs) => {
files.forEach((file) => {
if (/\/utils.ts$/.test(file)) {
// @see https://github.com/jprichardson/node-fs-extra
fs.appendFileSync(file, \nexport const DGH = 'DGH';\n);`
}
});
})
.on("end", () => {
console.log("dgh end");
});
| Options | Required | Description |
| ----------- | :------: | ------------------------------------ |
| owner | Y | github username or organization |repo
| | Y | github repository |name
| | Y | app name |root
| | N | app path, default process.cwd() |ref
| | N | github branch, default HEAD |subdir
| | N | repository subdirectory |overwrite
| | N | rewrite file content, default true |
- on('overwrite', (files, fs) => void)) - rewrite file content, the options overwrite must be trueon('end', () => void))
- files: all file paths
- fs: fs-extra instance
- - download complete callback eventon('info', () => void))
- - debug logs
`bash`
npx dgh \
--owner=
--repo=
--name=
--subdir=
--root=
`bash`
npm install -g dgh
| Args | Required | Description |
| ---------------- | :------: | --------------------------------- |
| -h or --help | | dgh command help |--owner
| | Y | github username or organization |--repo
| | Y | github repository |--name
| | Y | app name |--root
| | N | app path, default process.cwd() |--ref
| | N | github branch, default HEAD |--subdir
| | N | repository subdirectory |
`bash`test command 1
npx dgh \
--owner=lencx \
--repo="learn-wasm" \
--name="dgh-test-download" \
--root="my/path"
`bash`test command 2
npx dgh \
--owner=lencx \
--repo="learn-wasm" \
--name="dgh-test-download-2" \
--ref="gh-pages" \
--root="my/path"
`bash``test command 3
npx dgh \
--owner=lencx \
--repo="learn-wasm" \
--name="dgh-test-download-3" \
--ref="gh-pages" \
--subdir="assets" \
--root="my/path"
- create-mpl - ⚡️ Create a project in seconds!