Skip to content

Conversation

@mariuso
Copy link
Owner

@mariuso mariuso commented Jun 24, 2025

Summary

  • Fixed installation failures when the package is installed in directories containing spaces
  • Replaced gyp variable expansion with direct Node.js command execution for path resolution
  • Added comprehensive test coverage for spaces-in-path scenarios

Technical Details

The root cause was that gyp's <(variable) expansion mechanism generated unquoted paths in Makefiles, causing build failures when paths contained spaces. The solution replaces this with <\!(node -p ...) syntax which:

  1. Executes at configuration time: Paths are resolved when gyp generates the Makefile
  2. Properly handles spaces: Node's path.join() ensures correct path construction
  3. Avoids escaping complexity: No nested quoting issues with variable expansion

Changes Made

  • common.gypi: Replaced <(node_xmljs) variable expansion with direct <\!(node -p ...) commands
  • package.json: Bumped version to 1.0.9
  • test/spaces-in-path.js: Added comprehensive test for installation in paths with spaces

Test Results

✅ All existing tests pass
✅ New spaces-in-path test passes
✅ Package successfully installs and loads in directories with spaces

Testing

npm run test:spaces
npm test

mariuso added 19 commits June 23, 2025 23:17
- Update package.json with correct repository URLs and metadata
- Create .npmignore to exclude development files while keeping libxslt submodule
- Revert submodule initialization attempt in apply-patches.js
- Ready for npm publication as libxslt-next
- Quote node_xmljs path in common.gypi to handle spaces in directory names
- Remove problematic rpath setting that can cause issues with spaces
- Update README.md to use libxslt-next package name consistently
- Bump version to 1.0.1 for path fix
- Create index.d.ts with full type definitions for libxslt-next API
- Add custom libxmljs2 type definitions since @types/libxmljs2 doesn't exist
- Include TypeScript test file to validate type definitions
- Update package.json with types field, TypeScript keywords, and dev dependencies
- Add npm test:types script for TypeScript validation
- Update README.md with TypeScript usage examples and documentation
- Configure .npmignore to include TypeScript definitions in published package
- Add proper files field to package.json for explicit control over published files

Features:
- Built-in TypeScript definitions (no separate @types package needed)
- Full type safety for all synchronous and asynchronous API methods
- Comprehensive method overloads for different input/output types
- Compatible with TypeScript 3.0+ and modern IDEs
- Auto-completion and IntelliSense support
  - Restructure common.gypi to use target_defaults for better path handling
  - Remove complex path concatenation that breaks with spaces in directory names
  - Simplify libxslt.gyp by removing duplicate xmljs references
  - Remove unnecessary xmljs build dependency (already built by npm)
  - Use gyp's built-in features for consistent path resolution

  This fixes installation failures when the project path contains spaces,
  such as "XSLT Work" or "My Project".

  Fixes build error: "clang: error: no such file or directory"
- Quote patchPath in apply-patches.js to handle directory paths with spaces
- Fixes npm install failures when package is installed in paths containing spaces
- Use JSON.stringify to properly quote resolved libxmljs2 path in common.gypi
- Fixes compilation failures when package is installed in paths containing spaces
- Create test script to verify installation and compilation in directories with spaces
- Add test:spaces npm script for automated testing
- Test creates temporary directory with spaces and verifies package functionality
- Use sed to escape spaces in libxmljs2 path instead of JSON.stringify
- Should properly handle paths with spaces in gyp build system
- Use JSON.stringify then slice(1, -1) to remove quotes but keep proper escaping
- This should handle spaces in paths without breaking the path resolution
- Remove JSON.stringify approach that was causing issues
- Let gyp handle path quoting natively
- This should fix the spaces in path issue properly
Replace gyp variable expansion with direct node command execution
to properly handle paths containing spaces. This resolves installation
failures when the package is installed in directories with spaces.
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