-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a conditional JS preinstall script instead of BAT file
- Loading branch information
Andrej Mihajlov
committed
Aug 21, 2018
1 parent
9857fdf
commit 503acc5
Showing
3 changed files
with
32 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Yarn 1.9.4 has a path lookup bug on Windows, when it looks for the binaries referenced in | ||
// scripts under '\gui\node_modules\node_modules' instead of '\gui\node_modules'. | ||
// This patch adds a junction between those two to keep that house of cards from falling apart. | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
if (process.platform !== 'win32') { | ||
return; | ||
} | ||
|
||
const sourcePath = path.resolve(path.join(__dirname, '../../node_modules')); | ||
const symlinkPath = path.join(__dirname, '../../node_modules/node_modules'); | ||
|
||
try { | ||
console.log('Removing a symlink to node_modules/node_modules'); | ||
fs.unlinkSync(symlinkPath); | ||
} catch (error) { | ||
if (error.code !== 'ENOENT') { | ||
throw error; | ||
} | ||
} | ||
|
||
try { | ||
console.log('Applying yarn workspaces patch for node_modules/node_modules'); | ||
fs.symlinkSync(sourcePath, symlinkPath, 'junction'); | ||
console.log('Done'); | ||
} catch (error) { | ||
console.error('Cannot symlink node_modules/node_modules: ' + error.message); | ||
} |