⚙️ env
Reads an environment file and sets the environment variables.
History
| Version | Changes |
|---|---|
| v2.5.0 | --env-File in order to --envFile. |
CLI
Loading the .env by default:
npx poku --envFile
Loading a custom .env:
npx poku --envFile='path/to/my/.env'
API
You can set a
.envfile directly in a specif test or by using it globally.
Loading the .env by default:
import { envFile } from 'poku';
await envFile();
Loading a custom .env:
import { envFile, poku } from 'poku';
await envFile('path/to/my/.env');
await poku('./');
note
It's not possible to retrieve files from directories above the current process, e.g. ../.env.
danger
Poku is made entirely for testing purposes, please don't use this functionality outside of testing.
Real Examples
.env.test
HOST='localhost'
PORT='8080'
Then, in a test file, you can use it as:
import { assert } from 'poku';
const host = process.env.HOST;
const port = process.env.PORT;
// Your tests come here
Then, run your tests
npx poku --envFile='.env.test'