Skip to content

Commit

Permalink
fix: Add option to disable generator via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
bcanfield committed Aug 17, 2023
1 parent fd1e636 commit 9bc9ee7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ npx prisma generate
| exclude | Comma-separated list of model names to exclude from the top-level of the generated app (NOTE: If the 'include' option is used, this exclusion list will be ignored) | | false |
| depth | Maximum recursion depth for your models. (Changing this for large data models is not recommended, unless you filter down your models with the 'include' or 'exclude' flags also.) | 5 | false |

### Disabled
To disable Nexquik from generating during a Prisma generate, add the following environmental variable.
```zsh
DISABLE_NEXQUIK=true
```

## Examples
```prisma
Expand Down
4 changes: 4 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const defaultPrismaSchemaPath = "schema.prisma";

export async function run(options?: GeneratorOptions) {
try {
const disabled = process.env.DISABLE_NEXQUIK === "true";
if (disabled) {
return console.log("Nexquik generation disabled due to env var");
}
console.log(
chalk.bgYellow.blue.bold(
figlet.textSync("Nexquik", {
Expand Down
3 changes: 2 additions & 1 deletion templateRoot/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="file:./dev.db"
DATABASE_URL="file:./dev.db"
DISABLE_NEXQUIK=true
4 changes: 2 additions & 2 deletions templateRoot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "prisma db push --accept-data-loss && next dev",
"dev": "npm run generate && next dev",
"reset": "prisma migrate reset --force",
"build": "next build",
"start": "next start",
Expand All @@ -27,7 +27,7 @@
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"autoprefixer": "^10.4.15",
"nexquik": "^2.0.3",
"nexquik": "*",
"postcss": "^8.4.28",
"tailwindcss": "^3.3.3"
}
Expand Down

0 comments on commit 9bc9ee7

Please sign in to comment.