Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: use enhanced-resolve for node resolution #36

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions fixtures/custom-reporter/node_modules/dual/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import fs from 'fs';
import resolve from 'resolve';
import resolve from 'enhanced-resolve';
import { command as createCommand, Error as CliError } from 'clap';
import * as reporters from './reporter/index.js';
import { validatePath, validateString } from './helpers.js';
Expand Down Expand Up @@ -29,6 +29,10 @@ function printResult(result, reporter) {
}
}

const nodeResolver = resolve.create.sync({
conditionNames: ['node', 'import']
});

const command = createCommand('csstree-validate [fileOrDir]')
.version(version)
.option(
Expand All @@ -43,7 +47,7 @@ const command = createCommand('csstree-validate [fileOrDir]')

if (!hasOwnProperty.call(reporters, nameOrFile)) {
try {
const resolvedPath = resolve.sync(nameOrFile, { basedir: process.cwd() });
const resolvedPath = nodeResolver(process.cwd(), nameOrFile);
return import(resolvedPath);
} catch (e) {}

Expand Down
Loading
Loading