From 568364e620a1a103b37dacb7bad2cf160d200d08 Mon Sep 17 00:00:00 2001 From: David Worms Date: Tue, 31 Jan 2023 13:44:37 +0100 Subject: [PATCH] refactor(csv-issues-esm): use desm --- demo/issues-esm/lib/365.js | 10 ++++------ demo/issues-esm/package.json | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/demo/issues-esm/lib/365.js b/demo/issues-esm/lib/365.js index c160b0da3..c18e9feff 100644 --- a/demo/issues-esm/lib/365.js +++ b/demo/issues-esm/lib/365.js @@ -1,20 +1,18 @@ import fs from 'fs/promises' import { parse } from 'csv-parse/sync' -import { dirname, join } from 'path' -import { fileURLToPath } from 'url' +import desm from 'desm'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); +const dirname = desm(import.meta.url); (async () => { - const data = await fs.readFile(`${__dirname}/365-utf16le-bom-windows.csv`) + const data = await fs.readFile(`${dirname}/365-utf16le-bom-windows.csv`) const records = parse(data, {bom: true}) console.log('utf16le', records) })(); (async () => { - const data = await fs.readFile(`${__dirname}/365-utf8-bom-windows.csv`) + const data = await fs.readFile(`${dirname}/365-utf8-bom-windows.csv`) const records = parse(data, {bom: true}) console.log('utf8', records) })(); diff --git a/demo/issues-esm/package.json b/demo/issues-esm/package.json index 98326a3f8..5e946b0ec 100644 --- a/demo/issues-esm/package.json +++ b/demo/issues-esm/package.json @@ -24,5 +24,8 @@ }, "scripts": { "test": "mocha 'test/**/*.coffee'" + }, + "dependencies": { + "desm": "^1.3.0" } }