Skip to content

Commit

Permalink
Send to ui the last npm install log in create app
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopiraccini committed Dec 1, 2023
1 parent f938398 commit 689f79b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/main/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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!')
}
2 changes: 1 addition & 1 deletion test/main/create-app.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ test('Create app', async (t) => {
} catch (err) {
test.fails('Should have not thrown an error')
}
}, 50000)
}, 60000)

0 comments on commit 689f79b

Please sign in to comment.