From aff9d63f508bb9e791ee056bfa190fc8b33107cd Mon Sep 17 00:00:00 2001 From: briman0094 Date: Thu, 14 Mar 2019 08:42:55 -0500 Subject: [PATCH] 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 --- CHANGELOG.md | 4 ++++ __tests__/commands/global.js | 17 +++++++++++++++++ src/cli/commands/link.js | 2 +- src/fetchers/base-fetcher.js | 2 +- src/package-linker.js | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 047580f990..a11082c1a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/__tests__/commands/global.js b/__tests__/commands/global.js index d93e521576..269351f95c 100644 --- a/__tests__/commands/global.js +++ b/__tests__/commands/global.js @@ -90,6 +90,23 @@ test.concurrent("shouldn't expose unwanted binaries", async (): Promise => }); }); +test.concurrent("shouldn't create powershell shims", async (): Promise => { + 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 => { const tmpGlobalFolder = getTempGlobalFolder(); return runGlobal( diff --git a/src/cli/commands/link.js b/src/cli/commands/link.js index 1aa6d171c0..9c7595e892 100644 --- a/src/cli/commands/link.js +++ b/src/cli/commands/link.js @@ -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); } diff --git a/src/fetchers/base-fetcher.js b/src/fetchers/base-fetcher.js index 692809b036..25ddee18b5 100644 --- a/src/fetchers/base-fetcher.js +++ b/src/fetchers/base-fetcher.js @@ -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(); } diff --git a/src/package-linker.js b/src/package-linker.js index 0a8a8931a7..66ae879872 100644 --- a/src/package-linker.js +++ b/src/package-linker.js @@ -34,7 +34,7 @@ export async function linkBin(src: string, dest: string): Promise { if (process.platform === 'win32') { const unlockMutex = await lockMutex(src); try { - await cmdShim(src, dest); + await cmdShim(src, dest, {createPwshFile: false}); } finally { unlockMutex(); }