11#!/usr/bin/env node
2- // Usage: tools/update-author.js [--dry]
2+ // Usage: tools/update-author.mjs [--dry]
33// Passing --dry will redirect output to stdout rather than write to 'AUTHORS'.
4- 'use strict' ;
5- const { spawn } = require ( 'child_process' ) ;
6- const path = require ( 'path' ) ;
7- const fs = require ( 'fs' ) ;
8- const readline = require ( 'readline' ) ;
4+ import { spawn } from 'node:child_process' ;
5+ import fs from 'node:fs' ;
6+ import readline from 'node:readline' ;
97
108class CaseIndifferentMap {
119 _map = new Map ( ) ;
@@ -33,7 +31,7 @@ output.write('# Authors ordered by first contribution.\n\n');
3331
3432const mailmap = new CaseIndifferentMap ( ) ;
3533{
36- const lines = fs . readFileSync ( path . resolve ( __dirname , '../' , '.mailmap' ) ,
34+ const lines = fs . readFileSync ( new URL ( '../.mailmap ' , import . meta . url ) ,
3735 { encoding : 'utf8' } ) . split ( '\n' ) ;
3836 for ( let line of lines ) {
3937 line = line . trim ( ) ;
@@ -55,7 +53,7 @@ const mailmap = new CaseIndifferentMap();
5553
5654const previousAuthors = new CaseIndifferentMap ( ) ;
5755{
58- const lines = fs . readFileSync ( path . resolve ( __dirname , '../' , 'AUTHORS' ) ,
56+ const lines = fs . readFileSync ( new URL ( '../AUTHORS ' , import . meta . url ) ,
5957 { encoding : 'utf8' } ) . split ( '\n' ) ;
6058 for ( let line of lines ) {
6159 line = line . trim ( ) ;
@@ -112,5 +110,5 @@ rl.on('line', (line) => {
112110} ) ;
113111
114112rl . on ( 'close' , ( ) => {
115- output . end ( '\n# Generated by tools/update-authors.js \n' ) ;
113+ output . end ( '\n# Generated by tools/update-authors.mjs \n' ) ;
116114} ) ;
0 commit comments