Skip to content

Commit 4441ab6

Browse files
committed
chore: add predev script to check node version and env file
1 parent c194a2c commit 4441ab6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
"ee:check": "infisical run --env=remote -- turbo run ee:check",
5656
"ee:build:all": "dotenv -e .env.local -- turbo run ee:build --cache-dir=.turbo",
5757
"mock:incoming-mail": "dotenv -e .env.local -- pnpm --dir apps/mail-bridge mock:incoming-mail",
58-
"prepare": "husky"
58+
"prepare": "husky",
59+
"predev": "tsx predev.ts"
5960
},
6061
"keywords": [],
6162
"author": "Omar McAdam - @McPizza0",

predev.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { lstatSync, readFileSync } from 'fs';
2+
3+
// Check Node version
4+
const nodeVersion = process.version;
5+
const requiredVersion = readFileSync('.nvmrc', 'utf-8').trim();
6+
7+
if (!nodeVersion.startsWith(requiredVersion)) {
8+
console.error(
9+
`You are using Node ${nodeVersion}, but this project requires Node ${requiredVersion}.\nUse the correct node version to run this project`
10+
);
11+
process.exit(1);
12+
}
13+
14+
// Check for env file
15+
const envFile = lstatSync('.env.local', { throwIfNoEntry: false });
16+
if (!envFile?.isFile()) {
17+
console.error(
18+
'You are missing a .env.local file. Please refer to the README for instructions on how to create one.'
19+
);
20+
process.exit(1);
21+
}

0 commit comments

Comments
 (0)