Skip to content

Commit b4e3305

Browse files
authored
Merge pull request #2 from neonexus/master
Fixed a couple README issues.
2 parents c2ef7c2 + 7734d3c commit b4e3305

File tree

7 files changed

+24
-16
lines changed

7 files changed

+24
-16
lines changed

.idea/dictionaries/neonexus.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ OR
4040

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

43-
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:
43+
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:
4444

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

9696
* `drfg`
97-
* `dl-zip-from-gh`
98-
* `download-zip-from-gh`
99-
* `download-zip-from-github`
100-
* `download-zipball-from-gh`
101-
* `download-zipball-from-github`
97+
* `dl-rl-from-gh`
98+
* `download-rl-from-gh`
99+
* `download-rl-from-github`
100+
* `download-release-from-gh`
101+
* `download-release-from-github`
102102

103103
## Programmatic Usage
104104

example-update.png

-220 Bytes
Loading

gpl.svg

Lines changed: 6 additions & 0 deletions
Loading

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drfg",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Download Release From GitHub, extract it into a new directory, and install dependencies, with a single command.",
55
"bin": {
66
"drfg": "src/bin.js",

src/lib.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const reqOptions = {
1818

1919
// Private functions
2020
const lib = {
21-
downloadZipball: (zipballUrl) => new Promise((resolve, reject) => {
21+
downloadRelease: (zipballUrl) => new Promise((resolve, reject) => {
2222
if (!zipballUrl || zipballUrl === '') {
2323
return reject('Zipball URL is required.');
2424
}
@@ -53,7 +53,7 @@ const lib = {
5353
downloadIt(zipballUrl);
5454
}),
5555

56-
extractZipball: (destinationFolder) => new Promise((resolve, reject) => {
56+
extractRelease: (destinationFolder) => new Promise((resolve, reject) => {
5757
let dirToBeMoved;
5858
let extractedSize = 0;
5959

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

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

166166
const downloadStartTime = process.hrtime();
167167

168168
drfg.getVersionInfo(repo, version).then((release) => {
169-
lib.downloadZipball(release.zipball).then((zipballSize) => {
169+
lib.downloadRelease(release.zipball).then((zipballSize) => {
170170
const downloadTimeElapsed = process.hrtime(downloadStartTime);
171171
const extractionStartTime = process.hrtime();
172172

173-
lib.extractZipball(destinationFolder).then(async (extractedSize) => {
173+
lib.extractRelease(destinationFolder).then(async (extractedSize) => {
174174
const extractionTimeElapsed = process.hrtime(extractionStartTime);
175175

176176
const installationStartTime = process.hrtime();
@@ -247,7 +247,7 @@ const drfg = {
247247
res.on('end', () => {
248248
const release = JSON.parse(data);
249249

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

0 commit comments

Comments
 (0)