Skip to content

Commit aff9d63

Browse files
briman0094arcanis
authored andcommitted
Disable creation of cmdShim PowerShell shims because they don't work and cause problems (#6954)
* Disable creation of cmdShim PowerShell shims because they don't work and cause problems * Fix PowerShell test on non-Windows platforms * Fix lint error * Update CHANGELOG.md
1 parent bb69888 commit aff9d63

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa
44

55
## Master
66

7+
- Reverts a behavior causing boggus interactions between PowerShell and `yarn global`
8+
9+
[#6954](https://github.com/yarnpkg/yarn/pull/6954) - [**briman0094**](https://github.com/briman0094)
10+
711
- Fixes a bug where non-zero exit codes were converted to a generic 1 when running `yarn run`
812

913
[#6926](https://github.com/yarnpkg/yarn/pull/6926) - [**Kyle Fang**](https://github.com/zhigang1992)

__tests__/commands/global.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ test.concurrent("shouldn't expose unwanted binaries", async (): Promise<void> =>
9090
});
9191
});
9292

93+
test.concurrent("shouldn't create powershell shims", async (): Promise<void> => {
94+
const tmpGlobalFolder = await createTempGlobalFolder();
95+
const tmpPrefixFolder = await createTempPrefixFolder();
96+
const flags = {globalFolder: tmpGlobalFolder, prefix: tmpPrefixFolder};
97+
const isWindows = process.platform === 'win32';
98+
return runGlobal(['add', 'react-native-cli'], flags, 'add-with-prefix-flag', async config => {
99+
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native'))).toEqual(true);
100+
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.cmd'))).toEqual(isWindows);
101+
102+
// Should not have any ps1 shims whatsoever (including erroneous double-extension ones)
103+
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.ps1'))).toEqual(false);
104+
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.ps1.ps1'))).toEqual(false);
105+
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.ps1.cmd'))).toEqual(false);
106+
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.cmd.ps1'))).toEqual(false);
107+
});
108+
});
109+
93110
test.concurrent('bin', (): Promise<void> => {
94111
const tmpGlobalFolder = getTempGlobalFolder();
95112
return runGlobal(

src/cli/commands/link.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
7575
reporter.warn(reporter.lang('binLinkCollision', binName));
7676
} else {
7777
if (process.platform === 'win32') {
78-
await cmdShim(binSrcLoc, binDestLoc);
78+
await cmdShim(binSrcLoc, binDestLoc, {createPwshFile: false});
7979
} else {
8080
await fs.symlink(binSrcLoc, binDestLoc);
8181
}

src/fetchers/base-fetcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class BaseFetcher {
8181
if (process.platform === 'win32') {
8282
const unlockMutex = await lockMutex(src);
8383
try {
84-
await cmdShim.ifExists(src, `${binDest}/${binName}`);
84+
await cmdShim.ifExists(src, `${binDest}/${binName}`, {createPwshFile: false});
8585
} finally {
8686
unlockMutex();
8787
}

src/package-linker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function linkBin(src: string, dest: string): Promise<void> {
3434
if (process.platform === 'win32') {
3535
const unlockMutex = await lockMutex(src);
3636
try {
37-
await cmdShim(src, dest);
37+
await cmdShim(src, dest, {createPwshFile: false});
3838
} finally {
3939
unlockMutex();
4040
}

0 commit comments

Comments
 (0)