Skip to content

Commit 076362b

Browse files
authored
fix: Use the resolved root when setting Glob Root (#6027)
1 parent c49c244 commit 076362b

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Issue 6025
2+
3+
See: [#6025](https://github.com/streetsidesoftware/cspell/issues/6025)
4+
5+
The Glob Root was not getting correctly set:
6+
7+
Cause: [lint.ts#L406-L409](https://github.com/streetsidesoftware/cspell/pull/6004/files#diff-ef0c79008fac4e61b9dc76115f6847434e3db08e41cc4a8673cf84b35a103306L406-L409)
8+
9+
```diff
10+
async function run(): Promise<RunResult> {
11+
if (cfg.options.root) {
12+
- process.env[ENV_CSPELL_GLOB_ROOT] = cfg.root;
13+
+ setEnvironmentVariable(ENV_CSPELL_GLOB_ROOT, cfg.options.root);
14+
}
15+
```
16+
17+
`cfg.root` has been resolved, while `cfg.options.root` is still relative.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
overrides:
2+
- filename: sample/getting_started.md
3+
words:
4+
- funcignore
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Getting Started
2+
3+
```
4+
funcignore
5+
```

packages/cspell/src/app/lint/lint.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const samples = path.resolve(root, 'samples');
1414
const latexSamples = path.resolve(samples, 'latex');
1515
const failFastSamples = path.resolve(samples, 'fail-fast');
1616
const hiddenSamples = path.resolve(samples, 'hidden-test');
17-
const filesToCheck = path.resolve(root, 'fixtures/features/file-list/files-to-check.txt');
17+
const fixtures = path.resolve(root, 'fixtures');
18+
const features = path.resolve(fixtures, 'features');
19+
const filesToCheck = path.resolve(features, 'file-list/files-to-check.txt');
1820
const filesToCheckWithMissing = path.resolve(root, 'fixtures/features/file-list/files-to-check-missing.txt');
1921
const configSamples = path.resolve(samples, 'config');
2022

@@ -72,6 +74,7 @@ describe('Linter Validation Tests', () => {
7274
${[]} | ${{ ...optionsRootCSpellJson, files: ['README.md', 'missing.txt'], dot: true, mustFindFiles: true }} | ${oc({ errors: 1, files: 2 })} | ${oc({ errorCount: 1, errors: [expect.anything()], issues: [] })}
7375
${[]} | ${{ ...optionsRootCSpellJson, files: ['../../README.md'], dot: true }} | ${oc({ errors: 0, files: 1 })} | ${oc({ errorCount: 0, errors: [], issues: [] })}
7476
${[]} | ${{ ...optionsRootCSpellJson, files: ['../../resources/patreon.png' /* skip binary */], dot: true }} | ${oc({ errors: 0, files: 0 })} | ${oc({ errorCount: 0, errors: [], issues: [] })}
77+
${['**/*.md']} | ${{ root: './fixtures/issue-6025', config: './fixtures/issue-6025/nested/cspell.config.yaml' }} | ${oc({ errors: 0, files: 2 })} | ${oc({ errorCount: 0, errors: [], issues: [] })}
7578
`('runLint $files $options', async ({ files, options, expectedRunResult, expectedReport }) => {
7679
const reporter = new InMemoryReporter();
7780
const runResult = await runLint(new LintRequest(files, options, reporter));

packages/cspell/src/app/lint/lint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ export async function runLint(cfg: LintRequest): Promise<RunResult> {
418418

419419
async function run(): Promise<RunResult> {
420420
if (cfg.options.root) {
421-
setEnvironmentVariable(ENV_CSPELL_GLOB_ROOT, cfg.options.root);
421+
setEnvironmentVariable(ENV_CSPELL_GLOB_ROOT, cfg.root);
422422
}
423423

424424
const configInfo: ConfigInfo = await readConfig(cfg.configFile, cfg.root);

0 commit comments

Comments
 (0)