Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
260bfae
feat: allows yarn to get the current value when parsing the rcfile
jj811208 Oct 29, 2022
5f59a06
feat: let yarn merge all the values of the rc file in depth
jj811208 Oct 29, 2022
13f9901
test: test the behavior of "default", "merge", "reset", "overwrite" f…
jj811208 Oct 29, 2022
a8458cb
refactor: reverse the read order of rcfile
jj811208 Oct 29, 2022
4bdb6d9
feat: Implement the `onConflict` instead of `overwrite`,`reset` and `…
jj811208 Oct 29, 2022
8be0072
feat: Implement the top-level `onConflict`
jj811208 Oct 29, 2022
d42934f
test: onConflict test
jj811208 Oct 29, 2022
e04eb19
fix: fixes a problem where most strict settings were set to true
jj811208 Oct 29, 2022
5c2aecd
Mostly stylistic tweaks
arcanis Oct 31, 2022
47337a9
Fixes environment settings
arcanis Oct 31, 2022
2045193
Stops rc file traversal once the onConflict: reset is found at the to…
arcanis Oct 31, 2022
c9a28bf
Fixes array reset
arcanis Oct 31, 2022
ab3dfae
Fixes lint
arcanis Oct 31, 2022
e219a94
Fixes test
arcanis Oct 31, 2022
32772b5
Fixes a test
arcanis Oct 31, 2022
9007eee
revert: `Configuration.ts` change
jj811208 Nov 3, 2022
d661f54
revert: useWithSource overwrite change
jj811208 Nov 3, 2022
d334cb6
revert: useWithSource test
jj811208 Nov 3, 2022
4eeec9a
feat: use the `resolveRcFiles.ts` files suggested by code review
jj811208 Nov 3, 2022
d4e0db8
feat: make configuration.ts to use resolveRcFile to merge all settings
jj811208 Nov 3, 2022
7214ba4
test: `onConflict: extend` and `onConflict: hardReset` test
jj811208 Nov 3, 2022
6e8c1ac
Merge commit '345b687be77696d696d6e6a4fd4ea7cf718ba31e' into feat/mer…
jj811208 Nov 4, 2022
8d2d96d
Stylistic tweaks
arcanis Nov 8, 2022
c12c5a0
Merge remote-tracking branch 'origin/master' into pr/jj811208/4982
arcanis Nov 11, 2022
8b3807d
Strange immutable fail
arcanis Nov 11, 2022
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
Prev Previous commit
Next Next commit
feat: Implement the top-level onConflict
  • Loading branch information
jj811208 committed Oct 29, 2022
commit 8be0072ae507e526a329d541a92b5a4979da51a7
11 changes: 10 additions & 1 deletion packages/yarnpkg-core/sources/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,14 @@ export class Configuration {

use(source: string, data: {[key: string]: unknown}, folder: PortablePath, {strict = true}: {strict?: boolean} = {}) {
strict = strict && this.get(`enableStrictSettings`);
const onConflict = (data?.onConflict ?? `extend`) as string;

if (onConflict !== undefined && !onConflictList.includes(onConflict))
throw new UsageError(`the onConflict is invalid, it should be one of 'extend' | 'skip' | 'reset', but received ${onConflict}`);

const extend = onConflict === `extend`;
const skip = onConflict === `skip`;
const reset = onConflict === `reset`;

for (const key of [`enableStrictSettings`, ...Object.keys(data)]) {
// The plugins have already been loaded at this point
Expand All @@ -1524,6 +1532,7 @@ export class Configuration {
const definition = this.settings.get(key);
if (!definition) {
if (key === `enableStrictSettings`) continue;
if (key === `onConflict`) continue;

if (strict) {
throw new UsageError(`Unrecognized or legacy configuration settings found: ${key} - run "yarn config -v" to see the list of settings supported in Yarn`);
Expand All @@ -1535,7 +1544,7 @@ export class Configuration {

let parsed;
try {
parsed = parseValue(this, key, data[key], definition, folder);
parsed = parseValue(this, key, data[key], definition, folder, {extend, skip, reset});
} catch (error) {
error.message += ` in ${formatUtils.pretty(this, source, formatUtils.Type.PATH)}`;
throw error;
Expand Down