-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add predev script to check node version and env file (#772)
- Loading branch information
1 parent
05e599a
commit 55fd7b8
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |