Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.

Commit 14e9a2f

Browse files
authored
Merge pull request #1 from sefinek/codex/locate-and-fix-an-important-bug
Fix ES module examples
2 parents 56ee4f4 + 306406d commit 14e9a2f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

example/parse.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
const fs = require('node:fs');
2-
const path = require('node:path');
3-
const { parse } = require('../index.js');
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
import { parse } from '../index.js';
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
47

58
const ENV_PATH = path.resolve(__dirname, '.env');
69
const content = fs.readFileSync(ENV_PATH, 'utf8');
7-
810
const parsed = parse(content, { coerce: true });
911

1012
console.log('🧪 Parsed (typed values):');

example/process.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
console.time('execution');
22

3-
require('../index.js').config();
3+
import { config } from '../index.js';
4+
config({ path: './example/.env' });
45

56
const msg = process.env.GREETING;
67
console.log('process.env.GREETING:', msg);

example/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const { version } = require('../index.js');
1+
import { version } from '../index.js';
22

33
console.log('Version:', version);

0 commit comments

Comments
 (0)