Skip to content

Commit

Permalink
Merge pull request #11 - removing download dependency
Browse files Browse the repository at this point in the history
Removing dependency on download and using native download instead.
  • Loading branch information
evansiroky committed May 21, 2016
2 parents dccb7f8 + 337c514 commit 710fdf4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 23 additions & 9 deletions lib/update.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var fs = require('fs')
var fs = require('fs'),
http = require('http')

var async = require('async'),
Download = require('download'),
downloadStatus = require('download-status'),
mkdirp = require('mkdirp'),
rimraf = require('rimraf'),
shp = require('shpjs')

Expand Down Expand Up @@ -30,12 +30,26 @@ var extractToGeoJson = function(callback) {
}

var downloadFile = function(url, rename, callback) {
var download = new Download()
.get(url)
.dest('downloads')
.use(downloadStatus())
.rename(rename)
.run(callback)
var dlFile = 'downloads/' + rename
console.log('Downloading', url)
async.auto({
rm: function(cb) {
rimraf(dlFile, cb)
},
mkdir: ['rm', function(results, cb) {
mkdirp('downloads', cb)
}],
dl: ['mkdir', function(results, cb) {
var file = fs.createWriteStream(dlFile)
http.get(url, function(response) {
response.pipe(file)
file.on('finish', function() {
file.close(cb)
})
}).on('error', cb)
}]
}, callback)

}

var makeReadShaFileFn = function(filename) {
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"chai": "^3.5.0",
"codeclimate-test-reporter": "^0.3.1",
"cross-env": "^1.0.7",
"download": "^4.4.3",
"download-status": "^2.2.1",
"fs-extra": "^0.30.0",
"istanbul": "^0.4.2",
"jsts": "^1.1.2",
Expand Down

0 comments on commit 710fdf4

Please sign in to comment.