-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbvc
More file actions
executable file
·24 lines (19 loc) · 889 Bytes
/
bvc
File metadata and controls
executable file
·24 lines (19 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env node
// Simple wrapper that preserves the current working directory
const path = require('path');
// Find the project root (where package.json is) but don't change to it
const projectRoot = __dirname;
// Store the original working directory
const originalCwd = process.cwd();
// Temporarily add the project root to module paths so requires work
const Module = require('module');
const originalResolveFilename = Module._resolveFilename;
Module._resolveFilename = function(request, parent, isMain) {
// For relative requires starting with './', use the project root
if (request.startsWith('./') && parent && parent.filename === __filename) {
request = path.resolve(projectRoot, request.substring(2));
}
return originalResolveFilename.call(this, request, parent, isMain);
};
// Import and run the main CLI without changing directories
require('./bin/bvc.js');