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: fallback to resolve-from for Yarn P'n'P #3941

Merged
merged 2 commits into from
Feb 28, 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
3 changes: 2 additions & 1 deletion @commitlint/resolve-extends/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"@commitlint/types": "^19.0.0",
"global-directory": "^4.0.1",
"import-meta-resolve": "^4.0.0",
"lodash.mergewith": "^4.6.2"
"lodash.mergewith": "^4.6.2",
"resolve-from": "^5.0.0"
},
"gitHead": "d829bf6260304ca8d6811f329fcdd1b6c50e9749"
}
11 changes: 10 additions & 1 deletion @commitlint/resolve-extends/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {pathToFileURL, fileURLToPath} from 'url';
import globalDirectory from 'global-directory';
import {moduleResolve} from 'import-meta-resolve';
import mergeWith from 'lodash.mergewith';
import resolveFrom_ from 'resolve-from';
import {validateConfig} from '@commitlint/config-validator';
import type {ParserPreset, UserConfig} from '@commitlint/types';

Expand Down Expand Up @@ -58,7 +59,15 @@ export const resolveFrom = (lookup: string, parent?: string): string => {
}
}

throw resolveError;
try {
/**
* Yarn P'n'P does not support pure ESM well, this is only a workaround for
Copy link
Member

@escapedcat escapedcat Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we're not the only project breaking yarn p'n'p projects with a new major version

* @see https://github.com/conventional-changelog/commitlint/issues/3936
*/
return resolveFrom_(path.dirname(fileURLToPath(base)), lookup);
} catch {
throw resolveError;
}
};

/**
Expand Down