Skip to content

Commit

Permalink
fix(windows): CLI recognition of absolute paths on Windows (graphile#…
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie authored Oct 21, 2021
1 parent 3a19293 commit 666bf77
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/postgraphile/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,17 @@ const loadPlugins = (rawNames: mixed) => {
}
const name = String(rawName);
const parts = name.split(':');
if (
process.platform === 'win32' &&
parts[0].length === 1 &&
/^[a-z]$/i.test(parts[0]) &&
['\\', '/'].includes(name[2])
) {
// Assume this is a windows path `C:/path/to/module.js` or `C:\path\to\module.js`
const driveLetter = parts.shift();
// Add the drive part back onto the path
parts[0] = `${driveLetter}:${parts[0]}`;
}
let root;
try {
root = require(String(parts.shift()));
Expand Down

0 comments on commit 666bf77

Please sign in to comment.