Skip to content

chore: Make npm scripts cross-platform compatible#179

Merged
baelter merged 3 commits intomainfrom
chore/windows-compatibility
Nov 28, 2025
Merged

chore: Make npm scripts cross-platform compatible#179
baelter merged 3 commits intomainfrom
chore/windows-compatibility

Conversation

@carlhoerberg
Copy link
Copy Markdown
Member

Summary

  • Replace Unix-specific shell commands with Node.js scripts for Windows compatibility
  • Created scripts/clean.js to replace rm -rf with fs.rmSync()
  • Created scripts/write-cjs-package.js to replace echo redirect with fs.writeFileSync()
  • Created scripts/update-version.js to replace macOS-specific sed command with Node.js file operations

Changes

prebuild script:

  • Before: rm -rf dist lib types
  • After: node scripts/clean.js

postbuild script:

  • Before: echo '{"type": "commonjs"}' > lib/cjs/package.json
  • After: node scripts/write-cjs-package.js

version script:

  • Before: sed -i '' "s/VERSION = .*/VERSION = \"$npm_package_version\"/" src/amqp-base-client.ts && ...
  • After: node scripts/update-version.js && ...

Benefits

  • ✅ Works identically on Windows, macOS, and Linux
  • ✅ No additional dependencies (uses Node.js built-in APIs)
  • ✅ More maintainable and readable than shell one-liners
  • ✅ Already requires Node.js ≥16, so fs.rmSync() is guaranteed to be available

Test plan

  • Verify npm run prebuild successfully removes dist/lib/types directories
  • Verify npm run build completes successfully
  • Verify lib/cjs/package.json is created correctly with {"type": "commonjs"}
  • Test on Windows environment to ensure all scripts work

🤖 Generated with Claude Code

@carlhoerberg
Copy link
Copy Markdown
Member Author

Fixes #164

carlhoerberg and others added 3 commits November 28, 2025 08:25
Replace Unix-specific shell commands with Node.js scripts to ensure
compatibility across Windows, macOS, and Linux:

- Replace `rm -rf` with fs.rmSync() in prebuild script
- Replace `echo` redirect with fs.writeFileSync() in postbuild script
- Replace macOS-specific `sed` command with Node.js file operations in version script

All scripts use Node.js built-in APIs (fs, path) with no additional dependencies.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@baelter baelter force-pushed the chore/windows-compatibility branch from 7afd705 to 70d8e3e Compare November 28, 2025 07:25
@baelter baelter merged commit 7e18dcc into main Nov 28, 2025
6 checks passed
@baelter baelter deleted the chore/windows-compatibility branch November 28, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants