Skip to content

Commit

Permalink
fix: make relativePath OS safe
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Sep 11, 2023
1 parent 15b8f75 commit eaec901
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export namespace Command {
permutations?: string[]
aliasPermutations?: string[];
isESM?: boolean;
relativePath?: string;
relativePath?: string[];
}

export type Flag = CompletableFlag<any>
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class Plugin implements IPlugin {
cmd.id = id
cmd.plugin = this
cmd.isESM = isESM
cmd.relativePath = path.relative(this.root, filePath || '')
cmd.relativePath = path.relative(this.root, filePath || '').split(path.sep)
return cmd
}

Expand Down
2 changes: 1 addition & 1 deletion src/module-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class ModuleLoader {
throw new ModuleLoadError(`Cached command ${id} does not have the isESM property set`)
}

const filePath = path.join(modulePath, relativePath)
const filePath = path.join(modulePath, relativePath.join(path.sep))
try {
const module = isESM ? await import(url.pathToFileURL(filePath).href) : require(filePath)
return {isESM, module, filePath}
Expand Down

0 comments on commit eaec901

Please sign in to comment.