Skip to content

Commit

Permalink
Add a conditional JS preinstall script instead of BAT file
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrej Mihajlov committed Aug 21, 2018
1 parent 9857fdf commit 503acc5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
5 changes: 2 additions & 3 deletions gui/packages/yarn-fixes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"name": "yarn-fixes",
"version": "0.1.0",
"scripts": {
"preinstall": "patch-yarn.bat"
},
"os": ["win32"]
"preinstall": "node ./patch-yarn.js"
}
}
27 changes: 0 additions & 27 deletions gui/packages/yarn-fixes/patch-yarn.bat

This file was deleted.

30 changes: 30 additions & 0 deletions gui/packages/yarn-fixes/patch-yarn.js
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);
}

0 comments on commit 503acc5

Please sign in to comment.