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:
Shahed Nasser
2024-05-22 14:41:45 +03:00
committed by GitHub
parent 6ab7cbd529
commit 24a2ab754a

View File

@@ -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({