Skip to content

Commit

Permalink
chore: add predev script to check node version and env file (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlankParticle authored Sep 11, 2024
1 parent 05e599a commit 55fd7b8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"ee:check": "infisical run --env=remote -- turbo run ee:check",
"ee:build:all": "dotenv -e .env.local -- turbo run ee:build --cache-dir=.turbo",
"mock:incoming-mail": "dotenv -e .env.local -- pnpm --dir apps/mail-bridge mock:incoming-mail",
"prepare": "husky"
"prepare": "husky",
"predev": "tsx predev.ts"
},
"keywords": [],
"author": "Omar McAdam - @McPizza0",
Expand Down
21 changes: 21 additions & 0 deletions predev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { lstatSync, readFileSync } from 'fs';

// Check Node version
const nodeVersion = process.version;
const requiredVersion = readFileSync('.nvmrc', 'utf-8').trim();

if (!nodeVersion.startsWith(requiredVersion)) {
console.error(
`You are using Node ${nodeVersion}, but this project requires Node ${requiredVersion}.\nUse the correct node version to run this project`
);
process.exit(1);
}

// Check for env file
const envFile = lstatSync('.env.local', { throwIfNoEntry: false });
if (!envFile?.isFile()) {
console.error(
'You are missing a .env.local file. Please refer to the README for instructions on how to create one.'
);
process.exit(1);
}

0 comments on commit 55fd7b8

Please sign in to comment.