Skip to content

Commit

Permalink
Fixed a couple README issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
neonexus committed Oct 30, 2023
1 parent 94a6f02 commit 7734d3c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .idea/dictionaries/neonexus.xml

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

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ OR

`npx drfg <github-repo> <new-folder-name>`

For example, if you wanted to "clone" (download the zipball, and extract it) the repo [sails-react-bootstrap-webpack](https://github.com/neonexus/sails-react-bootstrap-webpack), just do something like:
For example, if you wanted to "clone" (download/extract/install) the repo [sails-react-bootstrap-webpack](https://github.com/neonexus/sails-react-bootstrap-webpack), just do something like:

```shell
npx drfg neonexus/sails-react-bootstrap-webpack
Expand Down Expand Up @@ -94,11 +94,11 @@ This does **not** prevent you from using the version you already have installed,
Once installed globally, you can use `drfg` directly, with one of its few different binary names:

* `drfg`
* `dl-zip-from-gh`
* `download-zip-from-gh`
* `download-zip-from-github`
* `download-zipball-from-gh`
* `download-zipball-from-github`
* `dl-rl-from-gh`
* `download-rl-from-gh`
* `download-rl-from-github`
* `download-release-from-gh`
* `download-release-from-github`

## Programmatic Usage

Expand Down
Binary file modified example-update.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions gpl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 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": "drfg",
"version": "0.0.2",
"version": "0.0.3",
"description": "Download Release From GitHub, extract it into a new directory, and install dependencies, with a single command.",
"bin": {
"drfg": "src/bin.js",
Expand Down
14 changes: 7 additions & 7 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const reqOptions = {

// Private functions
const lib = {
downloadZipball: (zipballUrl) => new Promise((resolve, reject) => {
downloadRelease: (zipballUrl) => new Promise((resolve, reject) => {
if (!zipballUrl || zipballUrl === '') {
return reject('Zipball URL is required.');
}
Expand Down Expand Up @@ -53,7 +53,7 @@ const lib = {
downloadIt(zipballUrl);
}),

extractZipball: (destinationFolder) => new Promise((resolve, reject) => {
extractRelease: (destinationFolder) => new Promise((resolve, reject) => {
let dirToBeMoved;
let extractedSize = 0;

Expand Down Expand Up @@ -159,18 +159,18 @@ const drfg = {
return reject('Repository must be in the format "username/repo".');
}

if (fs.existsSync(destinationFolder)) {
return reject('The folder "' + destinationFolder + '" already exists.');
if (fs.existsSync(destinationFolder) && getDirectorySize(destinationFolder)) {
return reject('The folder "' + destinationFolder + '" already exists, and is not empty.');
}

const downloadStartTime = process.hrtime();

drfg.getVersionInfo(repo, version).then((release) => {
lib.downloadZipball(release.zipball).then((zipballSize) => {
lib.downloadRelease(release.zipball).then((zipballSize) => {
const downloadTimeElapsed = process.hrtime(downloadStartTime);
const extractionStartTime = process.hrtime();

lib.extractZipball(destinationFolder).then(async (extractedSize) => {
lib.extractRelease(destinationFolder).then(async (extractedSize) => {
const extractionTimeElapsed = process.hrtime(extractionStartTime);

const installationStartTime = process.hrtime();
Expand Down Expand Up @@ -247,7 +247,7 @@ const drfg = {
res.on('end', () => {
const release = JSON.parse(data);

if (release.message === 'Not Found' || !release.tag_name || release.tag_name === '' || !release.zipball_url || release.zipball_url === '') {
if (res.statusCode !== 200 || release.message === 'Not Found' || !release.tag_name || release.tag_name === '' || !release.zipball_url || release.zipball_url === '') {
return reject(
'\nVersion "' + version.replace('tags/', '') + '" of the repo "' + repo + '" does not seem to exist. Make sure the repo is using GitHub Releases.' +
'\n\nRequest made to: ' + reqUrl + '\n'
Expand Down

0 comments on commit 7734d3c

Please sign in to comment.