Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a07f46
commit 5730d3f
Showing
4 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Downloads vuejs into the static folder | ||
const staticPath = "static/"; | ||
const filePath = "vue.js"; | ||
const downloadUrl = "https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"; | ||
|
||
var http = require("https"); | ||
var fs = require("fs"); | ||
|
||
var download = function(url, dest, cb) { | ||
var file = fs.createWriteStream(dest); | ||
var request = http | ||
.get(url, function(response) { | ||
response.pipe(file); | ||
file.on("finish", function() { | ||
file.close(cb); // close() is async, call cb after close completes. | ||
}); | ||
}) | ||
.on("error", function(err) { | ||
// Handle errors | ||
fs.unlink(dest); // Delete the file async. (But we don't check the result) | ||
if (cb) cb(err.message); | ||
}); | ||
}; | ||
|
||
download(downloadUrl, staticPath + filePath, console.log); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters