diff --git a/scripts/build-meetings.ts b/scripts/build-meetings.ts index 30feba8a3dd7..8a0cd099529c 100644 --- a/scripts/build-meetings.ts +++ b/scripts/build-meetings.ts @@ -1,7 +1,11 @@ import assert from 'assert'; import { writeFileSync } from 'fs'; import { google } from 'googleapis'; -import { resolve } from 'path'; +import { dirname, resolve } from 'path'; +import { fileURLToPath } from 'url'; + +const currentFilePath = fileURLToPath(import.meta.url); +const currentDirPath = dirname(currentFilePath); async function buildMeetings(writePath: string) { let auth; @@ -66,8 +70,8 @@ async function buildMeetings(writePath: string) { } /* istanbul ignore next */ -if (require.main === module) { - buildMeetings(resolve(__dirname, '../config', 'meetings.json')); +if (process.argv[1] === fileURLToPath(import.meta.url)) { + buildMeetings(resolve(currentDirPath, '../config', 'meetings.json')); } export { buildMeetings }; diff --git a/scripts/dashboard/build-dashboard.ts b/scripts/dashboard/build-dashboard.ts index 70024b9333ea..fa2ef96d437f 100644 --- a/scripts/dashboard/build-dashboard.ts +++ b/scripts/dashboard/build-dashboard.ts @@ -1,7 +1,8 @@ import { graphql } from '@octokit/graphql'; import assert from 'assert'; -import { writeFile } from 'fs-extra'; -import { resolve } from 'path'; +import { writeFile } from 'fs/promises'; +import { dirname, resolve } from 'path'; +import { fileURLToPath } from 'url'; import type { Discussion, @@ -16,6 +17,9 @@ import type { import { Queries } from './issue-queries'; +const currentFilePath = fileURLToPath(import.meta.url); +const currentDirPath = dirname(currentFilePath); + async function pause(ms: number): Promise { return new Promise((res) => { setTimeout(res, ms); @@ -210,8 +214,8 @@ async function start(writePath: string): Promise { } /* istanbul ignore next */ -if (require.main === module) { - start(resolve(__dirname, '..', '..', 'dashboard.json')); +if (process.argv[1] === fileURLToPath(import.meta.url)) { + start(resolve(currentDirPath, '..', '..', 'dashboard.json')); } export {