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
24 changes: 6 additions & 18 deletions packages/cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,22 @@ 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');
}
/* Attempt to look for the axe-core source in the CWD */
axePath = path.join(process.cwd(), 'axe.js');

if (!fs.existsSync(axePath)) {
// Look for axe in CWD ./node_modules
/* Attempt to look for the axe-core source in the 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'
);
/* Obtain the axe-core source from the globally installed CLI package instead */
axePath = path.join(__dirname, '..', 'node_modules', 'axe-core', 'axe.js');
Zidious marked this conversation as resolved.
Show resolved Hide resolved
}

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