Skip to content

Commit

Permalink
FIX: Change incorrect use of 'fs.createWriteStream'
Browse files Browse the repository at this point in the history
Thanks for the tip @ChALkeR

Closes #1
  • Loading branch information
sanusart committed Jun 15, 2015
1 parent c3704be commit 6b542f2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ build

node_modules
gists
!gists/.gitkeep
15 changes: 6 additions & 9 deletions gist-backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var prompt = require('synchro-prompt');

var ghUsername = process.argv[2] || prompt('Your GitHub Username? ');
var ghPassword = process.argv[3] || prompt('Your GitHub Password? ');
var savedir = process.argv[4] || prompt('Path to back-up dir (will create if not exists)? ');
var savedir = process.argv[4] || prompt('Path to back-up dir (will create if not exists)? ') || 'gists';

mkdirp(savedir);

Expand Down Expand Up @@ -59,14 +59,11 @@ function getGists(page) {
if (gist.files.hasOwnProperty(file)) {
var raw_url = gist.files[file].raw_url;
var filename = gist.files[file].filename;
request(raw_url).pipe(fs.createWriteStream(dir + '/' + filename, function (error) {
if (error) {
throw error;
} else {
console.log('successfully created ' + dir + '/' + filename);
}

}));
var streamed = fs.createWriteStream(dir + '/' + filename);
request(raw_url).pipe(streamed);
streamed.on('error', function(error){
console.log('Write error: ' + error);
});
}
}
});
Expand Down
Empty file removed gists/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gist-backup",
"version": "1.0.0",
"version": "1.0.1",
"description": "This script will download all gist files to local directory",
"main": "gist-backup.js",
"dependencies": {
Expand Down

0 comments on commit 6b542f2

Please sign in to comment.