Last active
August 29, 2015 14:19
-
-
Save seantunwin/81127112ccee9dfe7675 to your computer and use it in GitHub Desktop.
When using Nodejs with Cygwin it is sometimes helpful to convert DOS paths to linux with the Cygwin prefix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Convert slashes in DOS path strings to linux | |
| * @use replace(/\\/g, '/') | |
| * | |
| * And | |
| * | |
| * Replace drive letter and colon with 'cygwin/' then the drive letter | |
| * @use .replace(/^(\w):/i, 'cygwin/$1') | |
| **/ | |
| var dir = process.cwd().replace(/\\/g, '/').replace(/^(\w):/i, 'cygwin/$1'); | |
| /* NOTE: If using in a script, (i.e. not CLI), it is possible to substitute 'process.cwd()' | |
| * With '__dirname' | |
| * Or | |
| * If using 'require('path') then 'path.resolve() will also work | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment