From e0f4d05512c066c6282fd38f40e1243678b50bb1 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 26 Feb 2021 13:33:31 +0000 Subject: [PATCH] Fixing issue with init. --- packages/cli/src/hosting/index.js | 3 ++- packages/cli/src/utils.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/hosting/index.js b/packages/cli/src/hosting/index.js index a34a31a725..9655812b5c 100644 --- a/packages/cli/src/hosting/index.js +++ b/packages/cli/src/hosting/index.js @@ -29,7 +29,8 @@ async function init() { } const promises = [] for (let url of FILE_URLS) { - promises.push(downloadFile(url, __dirname)) + const fileName = url.split("/").slice(-1)[0] + promises.push(downloadFile(url, `./${fileName}`)) } await Promise.all(promises) console.log("Files have been downloaded, ready to start.") diff --git a/packages/cli/src/utils.js b/packages/cli/src/utils.js index 6a937b2f5c..5c43bbf9af 100644 --- a/packages/cli/src/utils.js +++ b/packages/cli/src/utils.js @@ -1,9 +1,11 @@ const chalk = require("chalk") const fs = require("fs") const axios = require("axios") +const path = require("path") -exports.downloadFile = async (url, path) => { - const writer = fs.createWriteStream(path) +exports.downloadFile = async (url, filePath) => { + filePath = path.resolve(filePath) + const writer = fs.createWriteStream(filePath) const response = await axios({ url,