brainctl 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +17 -3
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export interface CliServices {
|
|
|
12
12
|
}
|
|
13
13
|
export declare function createProgram(overrides?: Partial<CliServices>): Command;
|
|
14
14
|
export declare function main(argv?: string[]): Promise<void>;
|
|
15
|
+
export declare function shouldRunMain(entryPointPath: string | undefined, moduleUrl: string): boolean;
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
4
5
|
import { Command } from 'commander';
|
|
@@ -35,6 +36,12 @@ export async function main(argv = process.argv) {
|
|
|
35
36
|
process.exitCode = 1;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
export function shouldRunMain(entryPointPath, moduleUrl) {
|
|
40
|
+
if (!entryPointPath) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return resolveRealPath(entryPointPath) === resolveRealPath(fileURLToPath(moduleUrl));
|
|
44
|
+
}
|
|
38
45
|
function createDefaultServices(overrides) {
|
|
39
46
|
const resolver = createExecutorResolver();
|
|
40
47
|
return {
|
|
@@ -45,8 +52,15 @@ function createDefaultServices(overrides) {
|
|
|
45
52
|
...overrides
|
|
46
53
|
};
|
|
47
54
|
}
|
|
48
|
-
|
|
49
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
|
50
|
-
if (entryPointPath === currentFilePath) {
|
|
55
|
+
if (shouldRunMain(process.argv[1], import.meta.url)) {
|
|
51
56
|
void main();
|
|
52
57
|
}
|
|
58
|
+
function resolveRealPath(targetPath) {
|
|
59
|
+
const resolvedPath = path.resolve(targetPath);
|
|
60
|
+
try {
|
|
61
|
+
return realpathSync(resolvedPath);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return resolvedPath;
|
|
65
|
+
}
|
|
66
|
+
}
|