Skip to content

Commit

Permalink
fixed no content download bug
Browse files Browse the repository at this point in the history
  • Loading branch information
souvikinator committed Mar 31, 2021
1 parent d4e04e0 commit 5717630
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 67 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ Nodejs module to download/retrieve a specific directory or sub-directory from a

Any contribution is appreciated and please do report bugs if you find any.

- **v1.0.2**: previous fix lead to bug, not downloading file contents. Fixed now

- **v1.0.1**: fixed minor directory bug

## Todo:

- [] a bit slow! make it fast

## Installation

```js
Expand Down
125 changes: 63 additions & 62 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gh-retrieve",
"version": "1.0.1",
"version": "1.0.2",
"description": "Nodejs module to download/retrieve a specific directory from a GitHub repository",
"main": "gh-retrieve.js",
"dependencies": {
Expand Down
7 changes: 3 additions & 4 deletions utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ exports.downloadFiles = async function (fileList, outdir) {
let dirpath = path.join(outdir, filepath);
// createParentDir(dirpath);
let downloadUrl = fileList[filepath];
fs.ensureFile(dirpath,async (err) => {
if(err) throw new Error(err);
await download(downloadUrl);
});
// create file before downloading
fs.ensureFileSync(dirpath);
fs.writeFile(dirpath, await download(downloadUrl));
}
}

0 comments on commit 5717630

Please sign in to comment.