Skip to content

Commit

Permalink
fix: Use cmdshim instead of symlink on win32 in base-fetcher (#6621)
Browse files Browse the repository at this point in the history
* fix: Use cmdshim instead of symlink on win32 in base-fetcher

* Update CHANGELOG

* Bumps the cache key

* Use cmdShim.ifExists to handle missing src like symlink (ignores)

* Update CHANGELOG.md
  • Loading branch information
yoadsn authored and arcanis committed Nov 5, 2018
1 parent 4177b08 commit 4e3b2f6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 4e3b2f6

Please sign in to comment.