Skip to content

Commit

Permalink
refactor: update path resolution to use fileURLToPath for improved co…
Browse files Browse the repository at this point in the history
…mpatibility
  • Loading branch information
JeelRajodiya committed Dec 29, 2024
1 parent b3476a5 commit 9590dd1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions scripts/build-meetings.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 };
12 changes: 8 additions & 4 deletions scripts/dashboard/build-dashboard.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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<void> {
return new Promise((res) => {
setTimeout(res, ms);
Expand Down Expand Up @@ -210,8 +214,8 @@ async function start(writePath: string): Promise<void> {
}

/* 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 {
Expand Down

0 comments on commit 9590dd1

Please sign in to comment.