Skip to content

Commit 666bf77

Browse files
authored
fix(windows): CLI recognition of absolute paths on Windows (#1518)
1 parent 3a19293 commit 666bf77

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/postgraphile/cli.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,17 @@ const loadPlugins = (rawNames: mixed) => {
604604
}
605605
const name = String(rawName);
606606
const parts = name.split(':');
607+
if (
608+
process.platform === 'win32' &&
609+
parts[0].length === 1 &&
610+
/^[a-z]$/i.test(parts[0]) &&
611+
['\\', '/'].includes(name[2])
612+
) {
613+
// Assume this is a windows path `C:/path/to/module.js` or `C:\path\to\module.js`
614+
const driveLetter = parts.shift();
615+
// Add the drive part back onto the path
616+
parts[0] = `${driveLetter}:${parts[0]}`;
617+
}
607618
let root;
608619
try {
609620
root = require(String(parts.shift()));

0 commit comments

Comments
 (0)