-
-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(create-waku): install dependencies automatically when creating a new waku #728
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { | |
parseExampleOption, | ||
downloadAndExtract, | ||
} from './helpers/example-option.js'; | ||
import { spawn } from 'node:child_process'; | ||
|
||
const userAgent = process.env.npm_config_user_agent || ''; | ||
const packageManager = /pnpm/.test(userAgent) | ||
|
@@ -202,15 +203,40 @@ async function init() { | |
await installTemplate(root, packageName, templateRoot, templateName); | ||
} | ||
|
||
// TODO automatically installing dependencies | ||
// 1. check packageManager | ||
// 2. and then install dependencies | ||
|
||
console.log(`\nDone. Now run:\n`); | ||
console.log(`${bold(green(`cd ${targetDir}`))}`); | ||
console.log(`${bold(green(commands.install))}`); | ||
console.log(`${bold(green(commands.dev))}`); | ||
console.log(); | ||
console.log(`Installing dependencies by running ${commands.install}...`); | ||
|
||
process.chdir(targetDir); | ||
|
||
const installProcess = spawn(packageManager, ['install']); | ||
|
||
installProcess.stdout.setEncoding('utf8'); | ||
installProcess.stdout.on('data', (data) => { | ||
console.log(data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it show the indicator as expected? cc @ojj1123 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I could see the indicator as expected! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #728 (comment) I wonder if stdio: inherit works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs is explaining a difference between
|
||
}); | ||
|
||
installProcess.stderr.setEncoding('utf8'); | ||
installProcess.stderr.on('data', (data) => { | ||
console.log(data); | ||
}); | ||
|
||
installProcess.on('close', (code) => { | ||
// process exit code | ||
if (code !== 0) { | ||
console.error(`Could not execute ${commands.install}. Please run`); | ||
console.log(`${bold(green(`cd ${targetDir}`))}`); | ||
console.log(`${bold(green(commands.install))}`); | ||
console.log(`${bold(green(commands.dev))}`); | ||
console.log(); | ||
} else { | ||
console.log(`\nDone. Now run:\n`); | ||
console.log(`${bold(green(`cd ${targetDir}`))}`); | ||
console.log(`${bold(green(commands.dev))}`); | ||
console.log(); | ||
} | ||
}); | ||
} | ||
|
||
init() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @himself65,
encoding
is not a property that exists on the options object forspawn
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first to know this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think if you just wanna bypass the output, use
stdio: 'inherit'