Skip to content

Commit 54555db

Browse files
authored
Makes the path more specific
1 parent 55b86ac commit 54555db

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

sources/commands/Disable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class DisableCommand extends Command<Context> {
7272
try {
7373
const currentTarget = await fs.promises.realpath(file);
7474

75-
if (binName.includes(`yarn`) && currentTarget.match(/[/\\]switch[/\\]/)) {
75+
if (binName.includes(`yarn`) && currentTarget.match(/[/\\]switch[/\\]bin[/\\]/)) {
7676
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
7777
return;
7878
}

sources/commands/Enable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class EnableCommand extends Command<Context> {
8585
const currentSymlink = await fs.promises.readlink(file);
8686
const currentTarget = await fs.promises.realpath(file);
8787

88-
if (binName.includes(`yarn`) && currentTarget.match(/[/\\]switch[/\\]/)) {
88+
if (binName.includes(`yarn`) && currentTarget.match(/[/\\]switch[/\\]bin[/\\]/)) {
8989
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
9090
return;
9191
}

tests/Disable.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ describe(`DisableCommand`, () => {
100100

101101
it(`shouldn't remove Yarn binaries if they are in a /switch/ folder`, async () => {
102102
await xfs.mktempPromise(async cwd => {
103-
await xfs.mkdirPromise(ppath.join(cwd, `switch`));
104-
await xfs.writeFilePromise(ppath.join(cwd, `switch/yarn`), `hello`);
103+
await xfs.mkdirPromise(ppath.join(cwd, `switch/bin`), {recursive: true});
104+
await xfs.writeFilePromise(ppath.join(cwd, `switch/bin/yarn`), `hello`);
105105

106106
await xfs.linkPromise(
107-
ppath.join(cwd, `switch/yarn`),
107+
ppath.join(cwd, `switch/bin/yarn`),
108108
ppath.join(cwd, `yarn`),
109109
);
110110

tests/Enable.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ describe(`EnableCommand`, () => {
110110

111111
testNotWindows(`shouldn't overwrite Yarn files if they are in a /switch/ folder`, async () => {
112112
await xfs.mktempPromise(async cwd => {
113-
await xfs.mkdirPromise(ppath.join(cwd, `switch`));
114-
await xfs.writeFilePromise(ppath.join(cwd, `switch/yarn`), `hello`);
113+
await xfs.mkdirPromise(ppath.join(cwd, `switch/bin`), {recursive: true});
114+
await xfs.writeFilePromise(ppath.join(cwd, `switch/bin/yarn`), `hello`);
115115

116116
await xfs.linkPromise(
117-
ppath.join(cwd, `switch/yarn`),
117+
ppath.join(cwd, `switch/bin/yarn`),
118118
ppath.join(cwd, `yarn`),
119119
);
120120

0 commit comments

Comments
 (0)