Skip to content

Commit 029e3d8

Browse files
fix: Revert relative path handling for --output (#119)
1 parent 9a052a5 commit 029e3d8

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

packages/pyright-scip/src/MainCommand.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ export function mainCommand(
6464
.option('--project-namespace <namespace>', 'A prefix to prepend to all module definitions in the current index')
6565
.option('--cwd <path>', 'working directory for executing scip-python', process.cwd())
6666
.option('--target-only <path>', 'limit analysis to the following path')
67-
.option('--output <path>', 'path to the output file', DEFAULT_OUTPUT_FILE)
67+
.option(
68+
'--output <path>',
69+
'Path to the output file. If this path is relative, it is interpreted relative to the value for --cwd.',
70+
DEFAULT_OUTPUT_FILE
71+
)
6872
.option('--quiet', 'run without logging and status information', false)
6973
.option(
7074
'--show-progress-rate-limit <limit>',
@@ -85,7 +89,11 @@ export function mainCommand(
8589
.option('--only <name>', 'only generate snapshots for <name>')
8690
.requiredOption('--project-name <name>', 'the name of the current project, pypi name if applicable')
8791
.requiredOption('--project-version <version>', 'the name of the current project, pypi name if applicable')
88-
.option('--output <path>', 'path to the output file', DEFAULT_OUTPUT_FILE)
92+
.option(
93+
'--output <path>',
94+
'Path to the output file. If this path is relative, it is interpreted relative to the value for --cwd.',
95+
DEFAULT_OUTPUT_FILE
96+
)
8997
.option('--environment <json-file>', 'the environment json file (experimental)')
9098
.option('--no-index', 'skip indexing (use existing index.scip)')
9199
.option('--quiet', 'run without logging and status information', false)

packages/pyright-scip/src/main-impl.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ function indexAction(options: IndexOptions): void {
2222
const originalWorkdir = process.cwd();
2323
process.chdir(projectRoot);
2424

25-
const outputFile = path.isAbsolute(options.output) ? options.output : path.join(originalWorkdir, options.output);
25+
// In the relative path case, we use projectRoot rather than
26+
// originalWorkdir because:
27+
// 1. To preserve back-compat in case anyone is relying on projectRoot
28+
// 2. The actual CLI flag for specifying the project root is --cwd,
29+
// which may lead to the expectation that output is considered
30+
// relative to the project root.
31+
const outputFile = path.isAbsolute(options.output) ? options.output : path.join(projectRoot, options.output);
2632
const output = fs.openSync(outputFile, 'w');
2733

2834
try {

0 commit comments

Comments
 (0)