1.0.1 • Published 5 years ago

path-cygwin-patch v1.0.1

Weekly downloads
30
License
MIT
Repository
github
Last release
5 years ago

path-cygwin-patch

A npm module to replace methods of path to handle paths starting with '/' in Cygwin or MSYS2.

Description

The path module of Node.js does not handle paths starting with '/' in Cygwin or MSYS2, so sometimes yields an invalid path and causes a problem.

// On MSYS2

const path = require('path');

console.log(path.join('/c/Users', 'iorate/Documents')); // => \c\Users\iorate\Documents

This module exports nothing but patches path in Cygwin or MSYS2.

const path = require('path');
require('path-cygwin-patch');

console.log(path.join('/c/Users', 'iorate/Documents')); // => C:\Users\iorate\Documents

Some npm executables accept configuration files written in JavaScript. If such an executable has a problem on Cygwin or MSYS2, you can try to inject this module in a configuration file.

// .foorc.js

require('path-cygwin-patch');

module.exports = {
  // ...
};

Test

npm install

npm test

Known Issue

Patched functions are SLOW because they invoke cygpath internally.

Author

iorate (Twitter)

License

path-cygwin-patch is licensed under MIT License.