Files
medusa-store/packages/create-medusa-app/src/utils/run-process.ts
Shahed Nasser c04d93cd04 feat(create-medusa-app): update command for a better onboarding experience (#4215)
* feat(create-medusa-app): update command for a better onboarding experience

* use medusa-telemetry for tracking

* update used snapshot

* added changeset

* update yarn.lock

* increased facts timer

* updated snapshot version

* show facts throughout installation + add first_run to url

* added message after server termination

* print message only once

* added github to process terminated message

* address pr feedback

* added onboarding seeding

* fix for npm install
2023-06-07 20:34:50 +02:00

37 lines
900 B
TypeScript

type ProcessOptions = {
process: Function
ignoreERESOLVE?: boolean
}
// when running commands with npx or npm sometimes they
// terminate with EAGAIN error unexpectedly
// this utility function allows retrying the process if
// EAGAIN occurs, or otherwise throw the error that occurs
export default async ({ process, ignoreERESOLVE }: ProcessOptions) => {
let processError = false
do {
try {
await process()
} catch (error) {
if (
typeof error === "object" &&
error !== null &&
"code" in error &&
error?.code === "EAGAIN"
) {
processError = true
} else if (
ignoreERESOLVE &&
typeof error === "object" &&
error !== null &&
"code" in error &&
error?.code === "ERESOLVE"
) {
// ignore error
} else {
throw error
}
}
} while (processError)
}