Skip to content

Commit

Permalink
Fix ESM URL scheme compatibility issue in Windows (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Railly committed May 29, 2023
1 parent 62c6072 commit 4ddbcc9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/read-commands.ts
@@ -1,5 +1,6 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import {pathToFileURL} from 'node:url';
import decamelize from 'decamelize';
import type {CommandExports, Command} from './internal-types.js';

Expand Down Expand Up @@ -43,7 +44,8 @@ const readCommands = async (
continue;
}

const m = (await import(filePath)) as CommandExports;
const fileUrl = pathToFileURL(filePath);
const m = (await import(fileUrl.href)) as CommandExports;
const name = decamelize(file.replace(/\.(js|ts)x?$/, ''), {separator: '-'});

commands.set(name, {
Expand Down

0 comments on commit 4ddbcc9

Please sign in to comment.