File tree 2 files changed +7
-6
lines changed
2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 1
1
2
2
import fs from 'fs/promises'
3
3
import { parse } from 'csv-parse/sync'
4
- import { dirname , join } from 'path'
5
- import { fileURLToPath } from 'url'
4
+ import desm from 'desm' ;
6
5
7
- const __filename = fileURLToPath ( import . meta. url ) ;
8
- const __dirname = dirname ( __filename ) ;
6
+ const dirname = desm ( import . meta. url ) ;
9
7
10
8
( 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` )
12
10
const records = parse ( data , { bom : true } )
13
11
console . log ( 'utf16le' , records )
14
12
} ) ( ) ;
15
13
16
14
( 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` )
18
16
const records = parse ( data , { bom : true } )
19
17
console . log ( 'utf8' , records )
20
18
} ) ( ) ;
Original file line number Diff line number Diff line change 24
24
},
25
25
"scripts" : {
26
26
"test" : " mocha 'test/**/*.coffee'"
27
+ },
28
+ "dependencies" : {
29
+ "desm" : " ^1.3.0"
27
30
}
28
31
}
You can’t perform that action at this time.
0 commit comments