mirror of https://github.com/nodejs/corepack.git
Makes the path more specific
This commit is contained in:
parent
55b86aca65
commit
54555dbcf6
|
|
@ -72,7 +72,7 @@ export class DisableCommand extends Command<Context> {
|
||||||
try {
|
try {
|
||||||
const currentTarget = await fs.promises.realpath(file);
|
const currentTarget = await fs.promises.realpath(file);
|
||||||
|
|
||||||
if (binName.includes(`yarn`) && currentTarget.match(/[/\\]switch[/\\]/)) {
|
if (binName.includes(`yarn`) && currentTarget.match(/[/\\]switch[/\\]bin[/\\]/)) {
|
||||||
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
|
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ export class EnableCommand extends Command<Context> {
|
||||||
const currentSymlink = await fs.promises.readlink(file);
|
const currentSymlink = await fs.promises.readlink(file);
|
||||||
const currentTarget = await fs.promises.realpath(file);
|
const currentTarget = await fs.promises.realpath(file);
|
||||||
|
|
||||||
if (binName.includes(`yarn`) && currentTarget.match(/[/\\]switch[/\\]/)) {
|
if (binName.includes(`yarn`) && currentTarget.match(/[/\\]switch[/\\]bin[/\\]/)) {
|
||||||
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
|
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,11 +100,11 @@ describe(`DisableCommand`, () => {
|
||||||
|
|
||||||
it(`shouldn't remove Yarn binaries if they are in a /switch/ folder`, async () => {
|
it(`shouldn't remove Yarn binaries if they are in a /switch/ folder`, async () => {
|
||||||
await xfs.mktempPromise(async cwd => {
|
await xfs.mktempPromise(async cwd => {
|
||||||
await xfs.mkdirPromise(ppath.join(cwd, `switch`));
|
await xfs.mkdirPromise(ppath.join(cwd, `switch/bin`), {recursive: true});
|
||||||
await xfs.writeFilePromise(ppath.join(cwd, `switch/yarn`), `hello`);
|
await xfs.writeFilePromise(ppath.join(cwd, `switch/bin/yarn`), `hello`);
|
||||||
|
|
||||||
await xfs.linkPromise(
|
await xfs.linkPromise(
|
||||||
ppath.join(cwd, `switch/yarn`),
|
ppath.join(cwd, `switch/bin/yarn`),
|
||||||
ppath.join(cwd, `yarn`),
|
ppath.join(cwd, `yarn`),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,11 +110,11 @@ describe(`EnableCommand`, () => {
|
||||||
|
|
||||||
testNotWindows(`shouldn't overwrite Yarn files if they are in a /switch/ folder`, async () => {
|
testNotWindows(`shouldn't overwrite Yarn files if they are in a /switch/ folder`, async () => {
|
||||||
await xfs.mktempPromise(async cwd => {
|
await xfs.mktempPromise(async cwd => {
|
||||||
await xfs.mkdirPromise(ppath.join(cwd, `switch`));
|
await xfs.mkdirPromise(ppath.join(cwd, `switch/bin`), {recursive: true});
|
||||||
await xfs.writeFilePromise(ppath.join(cwd, `switch/yarn`), `hello`);
|
await xfs.writeFilePromise(ppath.join(cwd, `switch/bin/yarn`), `hello`);
|
||||||
|
|
||||||
await xfs.linkPromise(
|
await xfs.linkPromise(
|
||||||
ppath.join(cwd, `switch/yarn`),
|
ppath.join(cwd, `switch/bin/yarn`),
|
||||||
ppath.join(cwd, `yarn`),
|
ppath.join(cwd, `yarn`),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue