Skip to content

Commit

Permalink
fix: skip generation if command execution failed (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
7nohe authored Apr 27, 2023
1 parent 9000303 commit 9c2e79f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ export async function generate(options: CLIOptions) {
tmpDir,
`${modelName}.json`
)}`;
execSync(modelShowCommand);
const modelJson = JSON.parse(
fs.readFileSync(path.join(tmpDir, `${modelName}.json`), "utf8")
) as LaravelModelType;
modelData.push(modelJson);
try {
execSync(modelShowCommand);
const modelJson = JSON.parse(
fs.readFileSync(path.join(tmpDir, `${modelName}.json`), "utf8")
) as LaravelModelType;
modelData.push(modelJson);
} catch {
console.log(`Failed to generate ${modelName}. Skipping...`);
}
}

const modelSource = createModelSource(
Expand Down

0 comments on commit 9c2e79f

Please sign in to comment.