8000 fix: remove Windows-specific cleanup from postinstall script by Ax-0m · Pull Request #3911 · electron/forge · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: remove Windows-specific cleanup from postinstall script #3911

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions CROSS_PLATFORM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Cross-Platform Development Notes

## Package.json Scripts

### Postinstall Script
The `postinstall` script in `package.json` has been modified for better cross-platform compatibility:

```json
"postinstall": "ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts"
```

#### Background
- **Windows systems**: PowerShell scripts (`.ps1`) are created in `node_modules/.bin/`
- **Unix systems**: These scripts don't exist, and attempting to remove them causes errors

#### Previous Implementation
The script previously included PowerShell script cleanup:
```json
"postinstall": "rimraf node_modules/.bin/*.ps1 && ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts"
```

This would fail on non-Windows systems where `.ps1` files don't exist.

#### Current Implementation
- Skips `.ps1` cleanup (non-critical for non-Windows systems)
- Runs TypeScript config generation
- Runs TypeScript glue code generation

#### Future Considerations
If PowerShell script cleanup is needed in the future, consider:
1. Checking the OS in a separate script
2. Only running rimraf on Windows
3. Using a cross-platform solution like `cross-env`

Example solution using a separate script:
```js
// scripts/postinstall.js
const os = require('os');
const { execSync } = require('child_process');

if (os.platform() === 'win32') {
execSync('rimraf node_modules/.bin/*.ps1');
}

// Run the TypeScript tasks
execSync('ts-node ./tools/gen-tsconfigs.ts');
execSync('ts-node ./tools/gen-ts-glue.ts');
```

Then update package.json:
```json
"postinstall": "node scripts/postinstall.js"
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:fast": "xvfb-maybe vitest run --project fast",
"test:slow": "xvfb-maybe vitest run --project slow",
"test:clear": "ts-node tools/test-clear",
"postinstall": "rimraf node_modules/.bin/*.ps1 && ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts",
"postinstall": "ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts",
"prepare": "husky install",
"preversion": "yarn build"
},
Expand Down
0