Skip to content

Commit

Permalink
Fixes #1706 broken generator --watch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 committed Feb 27, 2020
1 parent b045a28 commit 5d6de4b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cli/prisma2/src/Generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export class Generate implements Command {
const name = generator.manifest ? generator.manifest.prettyName : generator.options!.generator.provider
const before = Date.now()
await generator.generate()
if (!watchMode) {
generator.stop()
}
generator.stop()
const after = Date.now()
message.push(`✔ Generated ${chalk.bold(name!)}${toStr} in ${formatms(after - before)}\n`)
}
Expand Down Expand Up @@ -102,6 +100,17 @@ export class Generate implements Command {

fs.watch(schemaPath, async eventType => {
if (eventType === 'change') {
const generators = await getGenerators({
schemaPath,
printDownloadProgress: !watchMode,
version: pkg.prisma.version,
cliVersion: pkg.version,
})

if (generators.length === 0) {
console.error(missingGeneratorMessage)
}

logUpdate(`\n${chalk.green('Building...')}\n\n${this.logText}`)
await this.runGenerate({ generators, watchMode })
logUpdate(watchingText + '\n' + this.logText)
Expand Down

0 comments on commit 5d6de4b

Please sign in to comment.