fix(create-medusa-app): fix seed step to use seed script in package.json (#7397)
Fix the seed step to use the `seed` script defined in `package.json` to avoid issues if the file is renamed or path is changed
This commit is contained in:
@@ -226,30 +226,17 @@ export default async ({
|
||||
title: "Seeding database...",
|
||||
})
|
||||
|
||||
const seedScriptPath = path.join("dist", "helpers", "seed.js")
|
||||
|
||||
// check if a seed file exists in the project
|
||||
if (!fs.existsSync(path.join(directory, seedScriptPath))) {
|
||||
spinner
|
||||
?.warn(
|
||||
chalk.yellow(
|
||||
"Seed file was not found in the project. Skipping seeding..."
|
||||
)
|
||||
)
|
||||
.start()
|
||||
return inviteToken
|
||||
}
|
||||
|
||||
await processManager.runProcess({
|
||||
process: async () => {
|
||||
await execute(
|
||||
[
|
||||
`npx medusa exec ${seedScriptPath}`,
|
||||
npxOptions,
|
||||
],
|
||||
{ verbose }
|
||||
)
|
||||
try {
|
||||
await execute([`yarn seed`, execOptions], { verbose })
|
||||
} catch (e) {
|
||||
// yarn isn't available
|
||||
// use npm
|
||||
await execute([`npm run seed`, execOptions], { verbose })
|
||||
}
|
||||
},
|
||||
ignoreERESOLVE: true,
|
||||
})
|
||||
|
||||
displayFactBox({
|
||||
|
||||
Reference in New Issue
Block a user