diff --git a/packages/generators/src/app/index.ts b/packages/generators/src/app/index.ts index cc31075cc9..2aabc1beb6 100644 --- a/packages/generators/src/app/index.ts +++ b/packages/generators/src/app/index.ts @@ -1,6 +1,7 @@ import { sep, dirname } from 'path' import chalk from 'chalk' import { prompt, runGenerators, fromFile, copyFiles, toFile } from '@featherscloud/pinion' +import { fileURLToPath } from 'url' import { FeathersBaseContext, FeathersAppInfo, @@ -11,7 +12,7 @@ import { import { generate as connectionGenerator, prompts as connectionPrompts } from '../connection/index.js' // Set __dirname in es module -const __dirname = dirname(new URL(import.meta.url).pathname) +const __dirname = dirname(fileURLToPath(import.meta.url)) export interface AppGeneratorData extends FeathersAppInfo { /** diff --git a/packages/generators/src/authentication/index.ts b/packages/generators/src/authentication/index.ts index 1ce1fa042f..12cea73aa2 100644 --- a/packages/generators/src/authentication/index.ts +++ b/packages/generators/src/authentication/index.ts @@ -1,6 +1,7 @@ import chalk from 'chalk' import { dirname } from 'path' import { runGenerators, prompt } from '@featherscloud/pinion' +import { fileURLToPath } from 'url' import { addVersions, checkPreconditions, @@ -11,7 +12,7 @@ import { import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index.js' // Set __dirname in es module -const __dirname = dirname(new URL(import.meta.url).pathname) +const __dirname = dirname(fileURLToPath(import.meta.url)) export interface AuthenticationGeneratorContext extends ServiceGeneratorContext { service: string diff --git a/packages/generators/src/commons.ts b/packages/generators/src/commons.ts index 2f75b377fc..9a284f36fb 100644 --- a/packages/generators/src/commons.ts +++ b/packages/generators/src/commons.ts @@ -16,9 +16,10 @@ import { import ts from 'typescript' import prettier, { Options as PrettierOptions } from 'prettier' import path from 'path' +import { fileURLToPath } from 'url' // Set __dirname in es module -const __dirname = dirname(new URL(import.meta.url).pathname) +const __dirname = dirname(fileURLToPath(import.meta.url)) export const { version } = JSON.parse(fs.readFileSync(join(__dirname, '..', 'package.json')).toString()) diff --git a/packages/generators/src/connection/index.ts b/packages/generators/src/connection/index.ts index 43ab705556..faffdd6d14 100644 --- a/packages/generators/src/connection/index.ts +++ b/packages/generators/src/connection/index.ts @@ -1,5 +1,6 @@ import { dirname } from 'path' import { runGenerator, prompt, mergeJSON, toFile, when } from '@featherscloud/pinion' +import { fileURLToPath } from 'url' import chalk from 'chalk' import { install, @@ -12,7 +13,7 @@ import { } from '../commons.js' // Set __dirname in es module -const __dirname = dirname(new URL(import.meta.url).pathname) +const __dirname = dirname(fileURLToPath(import.meta.url)) export interface ConnectionGeneratorContext extends FeathersBaseContext { name?: string diff --git a/packages/generators/src/hook/index.ts b/packages/generators/src/hook/index.ts index c96b50696a..fb4976b5ef 100644 --- a/packages/generators/src/hook/index.ts +++ b/packages/generators/src/hook/index.ts @@ -1,10 +1,11 @@ import { dirname } from 'path' +import { fileURLToPath } from 'url' import { prompt, runGenerators } from '@featherscloud/pinion' import _ from 'lodash' import { checkPreconditions, FeathersBaseContext, initializeBaseContext } from '../commons.js' // Set __dirname in es module -const __dirname = dirname(new URL(import.meta.url).pathname) +const __dirname = dirname(fileURLToPath(import.meta.url)) export interface HookGeneratorContext extends FeathersBaseContext { name: string diff --git a/packages/generators/src/service/index.ts b/packages/generators/src/service/index.ts index fa7b8f4536..f3268fde5b 100644 --- a/packages/generators/src/service/index.ts +++ b/packages/generators/src/service/index.ts @@ -1,11 +1,9 @@ import { dirname } from 'path' import _ from 'lodash' import { runGenerator, runGenerators, prompt } from '@featherscloud/pinion' +import { fileURLToPath } from 'url' import chalk from 'chalk' -// Set __dirname in es module -const __dirname = dirname(new URL(import.meta.url).pathname) - import { checkPreconditions, DATABASE_TYPES, @@ -15,6 +13,9 @@ import { initializeBaseContext } from '../commons.js' +// Set __dirname in es module +const __dirname = dirname(fileURLToPath(import.meta.url)) + export interface ServiceGeneratorContext extends FeathersBaseContext { /** * The chosen service name