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

fix: Use cmdshim instead of symlink on win32 in base-fetcher #6621

Merged
merged 6 commits into from Nov 5, 2018
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 @@ -16,6 +16,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

[#6611](https://github.com/yarnpkg/yarn/pull/6611) - [**Jack Zhao**](https://github.com/bugzpodder)

- Fixes an issue with how symlinks are setup into the cache on Windows

[#6621](https://github.com/yarnpkg/yarn/pull/6621) - [**Yoad Snapir**](https://github.com/yoadsn)

## 1.12.1

- Ensures the engine check is ran before showing the UI for `upgrade-interactive`
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Expand Up @@ -28,7 +28,7 @@ export const YARN_INSTALLER_MSI = 'https://yarnpkg.com/latest.msi';
export const SELF_UPDATE_VERSION_URL = 'https://yarnpkg.com/latest-version';

// cache version, bump whenever we make backwards incompatible changes
export const CACHE_VERSION = 3;
export const CACHE_VERSION = 4;

// lockfile version, bump whenever we make backwards incompatible changes
export const LOCKFILE_VERSION = 1;
Expand Down
13 changes: 12 additions & 1 deletion src/fetchers/base-fetcher.js
Expand Up @@ -9,7 +9,9 @@ import normalizeManifest from '../util/normalize-manifest/index.js';
import {makePortableProxyScript} from '../util/portable-script.js';
import * as constants from '../constants.js';
import * as fs from '../util/fs.js';
import lockMutex from '../util/mutex.js';

const cmdShim = require('@zkochan/cmd-shim');
const path = require('path');

export default class BaseFetcher {
Expand Down Expand Up @@ -77,7 +79,16 @@ export default class BaseFetcher {
}

await fs.mkdirp(binDest);
await fs.symlink(src, `${binDest}/${binName}`);
if (process.platform === 'win32') {
const unlockMutex = await lockMutex(src);
try {
await cmdShim.ifExists(src, `${binDest}/${binName}`);
} finally {
unlockMutex();
}
} else {
await fs.symlink(src, `${binDest}/${binName}`);
}
}
}

Expand Down