Skip to content

Commit

Permalink
Disable creation of cmdShim PowerShell shims because they don't work …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
briman0094 authored and arcanis committed Mar 14, 2019
1 parent bb69888 commit aff9d63
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Reverts a behavior causing boggus interactions between PowerShell and `yarn global`

[#6954](https://github.com/yarnpkg/yarn/pull/6954) - [**briman0094**](https://github.com/briman0094)

- Fixes a bug where non-zero exit codes were converted to a generic 1 when running `yarn run`

[#6926](https://github.com/yarnpkg/yarn/pull/6926) - [**Kyle Fang**](https://github.com/zhigang1992)
Expand Down
17 changes: 17 additions & 0 deletions __tests__/commands/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ test.concurrent("shouldn't expose unwanted binaries", async (): Promise<void> =>
});
});

test.concurrent("shouldn't create powershell shims", async (): Promise<void> => {
const tmpGlobalFolder = await createTempGlobalFolder();
const tmpPrefixFolder = await createTempPrefixFolder();
const flags = {globalFolder: tmpGlobalFolder, prefix: tmpPrefixFolder};
const isWindows = process.platform === 'win32';
return runGlobal(['add', 'react-native-cli'], flags, 'add-with-prefix-flag', async config => {
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native'))).toEqual(true);
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.cmd'))).toEqual(isWindows);

// Should not have any ps1 shims whatsoever (including erroneous double-extension ones)
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.ps1'))).toEqual(false);
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.ps1.ps1'))).toEqual(false);
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.ps1.cmd'))).toEqual(false);
expect(await fs.exists(path.join(tmpPrefixFolder, 'bin', 'react-native.cmd.ps1'))).toEqual(false);
});
});

test.concurrent('bin', (): Promise<void> => {
const tmpGlobalFolder = getTempGlobalFolder();
return runGlobal(
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
reporter.warn(reporter.lang('binLinkCollision', binName));
} else {
if (process.platform === 'win32') {
await cmdShim(binSrcLoc, binDestLoc);
await cmdShim(binSrcLoc, binDestLoc, {createPwshFile: false});
} else {
await fs.symlink(binSrcLoc, binDestLoc);
}
Expand Down
2 changes: 1 addition & 1 deletion src/fetchers/base-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class BaseFetcher {
if (process.platform === 'win32') {
const unlockMutex = await lockMutex(src);
try {
await cmdShim.ifExists(src, `${binDest}/${binName}`);
await cmdShim.ifExists(src, `${binDest}/${binName}`, {createPwshFile: false});
} finally {
unlockMutex();
}
Expand Down
2 changes: 1 addition & 1 deletion src/package-linker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function linkBin(src: string, dest: string): Promise<void> {
if (process.platform === 'win32') {
const unlockMutex = await lockMutex(src);
try {
await cmdShim(src, dest);
await cmdShim(src, dest, {createPwshFile: false});
} finally {
unlockMutex();
}
Expand Down

0 comments on commit aff9d63

Please sign in to comment.