Skip to content

Commit

Permalink
feat(crwrsca): More verbose install logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Sep 15, 2024
1 parent 44b0369 commit 18f2e3a
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions packages/create-redwood-rsc-app/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,38 @@ export function install(config: Config) {
console.log('🐈 Running `yarn install`')
console.log(' ⏳ This might take a while...')

if (config.verbose) {
console.log()
console.log('Installation directory contents before installing:')
fs.readdirSync(config.installationDir, { withFileTypes: true }).forEach(
(file) => {
console.log(' ' + file.name + (file.isDirectory() ? '/' : ''))
},
)
console.log()
}

// This allows us to run `yarn install` even if the parent directory is
// another node project (like if you try to set it up in a sub-directory if
// another node project (like if you try to set it up in a sub-directory of
// this project)
fs.writeFileSync(path.join(config.installationDir, 'yarn.lock'), '')

spawnSync('yarn', ['install'], {
const result = spawnSync('yarn', ['install'], {
cwd: config.installationDir,
// On Windows `yarn` isn't an executable. It can't be run as a system
// process. So it needs to be run in a shell process.
shell: process.platform === 'win32',
})

if (config.verbose) {
console.log('spawnSync result.status', result.status)
console.log('spawnSync result.stdout', result.stdout.toString())
console.log('spawnSync result.stderr', result.stderr.toString())
console.log()
console.log(
'yarn.lock file size (in kb)',
fs.statSync(path.join(config.installationDir, 'yarn.lock')).size / 1024,
)
console.log()
}
}

0 comments on commit 18f2e3a

Please sign in to comment.