From a696c3eaa68818cf74d35a4c333f05cf6a606c16 Mon Sep 17 00:00:00 2001 From: Thadeu Cotts Date: Tue, 24 Nov 2020 15:04:12 -0300 Subject: [PATCH] [refactor] [m]: update install method --- packages/create-portal-app/helpers/install.js | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/packages/create-portal-app/helpers/install.js b/packages/create-portal-app/helpers/install.js index e4f924b8..d2b51707 100644 --- a/packages/create-portal-app/helpers/install.js +++ b/packages/create-portal-app/helpers/install.js @@ -1,27 +1,28 @@ -const spawn = require('cross-spawn'); -const { resolve } = require('path'); -const path = require('path'); +const spawn = require("cross-spawn"); +const path = require("path"); -module.exports = function install(projectName, isYarn){ - return new Promise((resolve, reject)=>{ - const appPath = [process.cwd(), projectName].join(path.sep); - //change the directory to the app directory - process.chdir(appPath); - let command = isYarn ? "yarn": "npm"; - let args = isYarn ? [''] : ["install"]; - let exec = spawn(command,args, { - stdio: 'inherit', - env: { ...process.env, ADBLOCK: '1', DISABLE_OPENCOLLECTIVE: '1' }, - }) +function install(projectName, isYarn) { + return new Promise((resolve, reject) => { + const appPath = [process.cwd(), projectName].join(path.sep); + //change the directory to the app directory + process.chdir(appPath); - exec.on('close', (code)=>{ - if (code !== 0) { - reject({ command: `${command} ${args[0]}` }) - return - } - resolve() - }); + const command = isYarn ? "yarn" : "npm"; + const args = isYarn ? [""] : ["install"]; + const exec = spawn(command, args, { + stdio: "pipe", + env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" }, + }); + + exec.on("close", (code) => { + if (code !== 0) { + reject({ command: `${command} ${args[0]}` }); + return; + } + resolve(); + }); }); - -} \ No newline at end of file +} + +