Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable creation of cmdShim PowerShell shims because they don't work and cause problems #6954

Merged
merged 6 commits into from Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
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
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
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
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
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