1515 * /README.md
1616 */
1717
18- const os = require ( 'os' ) ;
19- const fs = require ( 'fs' ) ;
20- const path = require ( 'path' ) ;
21- const process = require ( 'process' ) ;
22- const childProcess = require ( 'child_process' ) ;
23- const packageJSON = require ( '../package.json' ) ;
18+ import os from 'node:os' ;
19+ import fs from 'node:fs' ;
20+ import path from 'node:path' ;
21+ import process from 'node:process' ;
22+ import childProcess from 'node:child_process' ;
23+ import url from 'node:url' ;
24+ import packageJSON from '../package.json' assert { type : 'json ' } ;
2425
2526const platform = os . platform ( ) ;
2627
28+ const projectPath = path . dirname (
29+ path . dirname ( url . fileURLToPath ( import . meta. url ) ) ,
30+ ) ;
31+
2732/* eslint-disable no-console */
2833async function main ( argv = process . argv ) {
2934 argv = argv . slice ( 2 ) ;
@@ -44,9 +49,8 @@ async function main(argv = process.argv) {
4449 if ( tag == null ) {
4550 tag = process . env . npm_config_tag ;
4651 }
47- const projectRoot = path . join ( __dirname , '..' ) ;
48- const prebuildPath = path . join ( projectRoot , 'prebuild' ) ;
49- const prepublishOnlyPath = path . join ( projectRoot , 'prepublishOnly' ) ;
52+ const prebuildPath = path . join ( projectPath , 'prebuild' ) ;
53+ const prepublishOnlyPath = path . join ( projectPath , 'prepublishOnly' ) ;
5054 const buildNames = ( await fs . promises . readdir ( prebuildPath ) ) . filter (
5155 ( filename ) => / ^ (?: [ ^ - ] + ) - (?: [ ^ - ] + ) - (?: [ ^ - ] + ) $ / . test ( filename ) ,
5256 ) ;
0 commit comments