Skip to content

Commit

Permalink
fix(ConfigManager): Resolve ESM import exception on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Jan 3, 2025
1 parent a94984d commit 9527181
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/linter/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {Minimatch} from "minimatch";
export async function lintProject({
rootDir, filePatterns, ignorePatterns, coverage, details, configPath, ui5Config, noConfig,
}: LinterOptions): Promise<LintResult[]> {
if (!path.isAbsolute(rootDir)) {
throw new Error(`rootDir must be an absolute path. Received: ${rootDir}`);
}
let config: UI5LintConfigType = {};
if (noConfig !== true) {
const configMngr = new ConfigManager(rootDir, configPath);
Expand Down
7 changes: 2 additions & 5 deletions src/utils/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ export default class ConfigManager {
}

#resolveModulePaths(fileName: string): string {
// Node on Windows behaves strange, does not work with absolute paths
// and modifies files extensions in tests i.e. js -> ts, mjs -> tjs
// Node on Windows behaves strange,it modifies files extensions in tests i.e. js -> ts, mjs -> tjs
// Keeping the relative path in POSIX format resolves those issues.
return path.posix.join(
path.relative(__dirname, this.#projectRootDir).replaceAll(path.win32.sep, path.posix.sep),
fileName);
return path.join(this.#projectRootDir, fileName);
}

async getConfiguration(): Promise<UI5LintConfigType> {
Expand Down

0 comments on commit 9527181

Please sign in to comment.