Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(packages/cli): revert ESM #730

Merged
merged 10 commits into from
May 30, 2023
28 changes: 3 additions & 25 deletions packages/cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,35 +71,13 @@ export const parseBrowser = (browser?: string): string | Error => {
};

export const getAxeSource = (axePath?: string): string | void => {
// Abort if axePath should exist, and it isn't
/* User has specified a path to axe-core, check if it exists */
if (axePath && !fs.existsSync(axePath)) {
return;
Zidious marked this conversation as resolved.
Show resolved Hide resolved
}

// Look for axe in current working directory
if (!axePath) {
axePath = path.join(process.cwd(), 'axe.js');
}

if (!fs.existsSync(axePath)) {
// Look for axe in CWD ./node_modules
axePath = path.join(process.cwd(), 'node_modules', 'axe-core', 'axe.js');
}

if (!fs.existsSync(axePath)) {
// `__dirname` is /@axe-core/cli/dist/src/lib when installed globally
// to access the locally installed axe-core package we need to go up 3 levels
// if all else fails, use the locally installed axe
axePath = path.join(
__dirname,
'..',
'..',
'..',
'node_modules',
'axe-core',
'axe.js'
);
}
/* Allow `require.resolve` to find the source */
axePath = require.resolve('axe-core');

return fs.readFileSync(axePath, 'utf-8');
};
Expand Down