Skip to content

Commit 568364e

Browse files
committed
refactor(csv-issues-esm): use desm
1 parent 8ce415a commit 568364e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

demo/issues-esm/lib/365.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11

22
import fs from 'fs/promises'
33
import { parse } from 'csv-parse/sync'
4-
import { dirname, join } from 'path'
5-
import { fileURLToPath } from 'url'
4+
import desm from 'desm';
65

7-
const __filename = fileURLToPath(import.meta.url);
8-
const __dirname = dirname(__filename);
6+
const dirname = desm(import.meta.url);
97

108
(async () => {
11-
const data = await fs.readFile(`${__dirname}/365-utf16le-bom-windows.csv`)
9+
const data = await fs.readFile(`${dirname}/365-utf16le-bom-windows.csv`)
1210
const records = parse(data, {bom: true})
1311
console.log('utf16le', records)
1412
})();
1513

1614
(async () => {
17-
const data = await fs.readFile(`${__dirname}/365-utf8-bom-windows.csv`)
15+
const data = await fs.readFile(`${dirname}/365-utf8-bom-windows.csv`)
1816
const records = parse(data, {bom: true})
1917
console.log('utf8', records)
2018
})();

demo/issues-esm/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
},
2525
"scripts": {
2626
"test": "mocha 'test/**/*.coffee'"
27+
},
28+
"dependencies": {
29+
"desm": "^1.3.0"
2730
}
2831
}

0 commit comments

Comments
 (0)