From 689f79b21cc3a3c01cebc46c94a93d7ccaee1c53 Mon Sep 17 00:00:00 2001 From: marcopiraccini Date: Fri, 1 Dec 2023 03:34:43 +0100 Subject: [PATCH] Send to ui the last npm install log in create app --- src/main/generate.mjs | 12 +++++++++++- test/main/create-app.test.mjs | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/generate.mjs b/src/main/generate.mjs index 3d1836c2..00491d7a 100644 --- a/src/main/generate.mjs +++ b/src/main/generate.mjs @@ -2,6 +2,7 @@ import { stat } from 'node:fs/promises' import { getPkgManager } from './lib/get-package-manager.mjs' import { importOrLocal } from './lib/import-or-local.mjs' import errors from './errors.mjs' +import split from 'split2' export const prepareFolder = async (path, tempNames, logger) => { const s = await stat(path) @@ -136,7 +137,16 @@ export const createApp = async (projectDir, { projectName, services, entrypoint, await generator.prepare() await generator.writeFiles() - await execa(pkgManager, ['install'], { cwd: projectDir }) + const child = execa(pkgManager, ['install'], { cwd: projectDir }) + + child.stdout.pipe(split()).on('data', (line) => { + logger.info(line) + }) + + child.stderr.pipe(split()).on('data', (line) => { + logger.error(line) + }) + await child logger.info('App created!') } diff --git a/test/main/create-app.test.mjs b/test/main/create-app.test.mjs index 6b137228..500dcd86 100644 --- a/test/main/create-app.test.mjs +++ b/test/main/create-app.test.mjs @@ -113,4 +113,4 @@ test('Create app', async (t) => { } catch (err) { test.fails('Should have not thrown an error') } -}, 50000) +}, 60000)