Skip to content

Commit

Permalink
build: add shim script for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
VerteDinde committed Nov 1, 2022
1 parent 181c8c3 commit d05eb38
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"lint:fix": "prettier --write .",
"test": "xvfb-maybe cross-env TS_NODE_PROJECT='./tsconfig.test.json' TS_NODE_FILES=1 mocha './tools/test-globber.ts'",
"test:fast": "xvfb-maybe cross-env TS_NODE_PROJECT='./tsconfig.test.json' TEST_FAST_ONLY=1 TS_NODE_FILES=1 mocha './tools/test-globber.ts'",
"preinstall": "npx mkdirp packages/api/cli/dist && npx mkdirp packages/external/create-electron-app/dist && touch packages/api/cli/dist/electron-forge.js && touch packages/external/create-electron-app/dist/index.js",
"preinstall": "node ./tools/maybe-shim-windows.js",
"postinstall": "rimraf node_modules/.bin/*.ps1 && ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts",
"prepare": "husky install"
},
Expand Down
27 changes: 27 additions & 0 deletions tools/maybe-shim-windows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const cp = require('child_process');

/*
* Adds a shim to fix Windows symlinking with create-electron-app.
* Should run on Windows only.
* More details: https://github.com/boltpkg/bolt/issues/207
*/
async function spawnProcess(cmd, shimPath) {
const child = cp.spawn('npx', [cmd, shimPath], {
stdio: 'inherit',
});
child.on('exit', (code) => process.exit(code));
}

async function main() {
spawnProcess('mkdirp', '../packages/api/cli/dist');
spawnProcess('mkdirp', '../packages/external/create-electron-app');
spawnProcess('touch', '../packages/api/cli/dist/electron-forge.js');
spawnProcess('touch', '../packages/external/create-electron-app/dist/index.js');
}

if (process.platform === 'win32') {
main().catch((err) => {
console.error(err);
process.exit(1);
});
}

0 comments on commit d05eb38

Please sign in to comment.