Skip to content

Commit

Permalink
fix: Use the resolved root when setting Glob Root (#6027)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Aug 2, 2024
1 parent c49c244 commit 076362b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
17 changes: 17 additions & 0 deletions packages/cspell/fixtures/issue-6025/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Issue 6025

See: [#6025](https://github.com/streetsidesoftware/cspell/issues/6025)

The Glob Root was not getting correctly set:

Cause: [lint.ts#L406-L409](https://github.com/streetsidesoftware/cspell/pull/6004/files#diff-ef0c79008fac4e61b9dc76115f6847434e3db08e41cc4a8673cf84b35a103306L406-L409)

```diff
async function run(): Promise<RunResult> {
if (cfg.options.root) {
- process.env[ENV_CSPELL_GLOB_ROOT] = cfg.root;
+ setEnvironmentVariable(ENV_CSPELL_GLOB_ROOT, cfg.options.root);
}
```

`cfg.root` has been resolved, while `cfg.options.root` is still relative.
1 change: 1 addition & 0 deletions packages/cspell/fixtures/issue-6025/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions packages/cspell/fixtures/issue-6025/nested/cspell.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
overrides:
- filename: sample/getting_started.md
words:
- funcignore
5 changes: 5 additions & 0 deletions packages/cspell/fixtures/issue-6025/sample/getting_started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Getting Started

```
funcignore
```
5 changes: 4 additions & 1 deletion packages/cspell/src/app/lint/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const samples = path.resolve(root, 'samples');
const latexSamples = path.resolve(samples, 'latex');
const failFastSamples = path.resolve(samples, 'fail-fast');
const hiddenSamples = path.resolve(samples, 'hidden-test');
const filesToCheck = path.resolve(root, 'fixtures/features/file-list/files-to-check.txt');
const fixtures = path.resolve(root, 'fixtures');
const features = path.resolve(fixtures, 'features');
const filesToCheck = path.resolve(features, 'file-list/files-to-check.txt');
const filesToCheckWithMissing = path.resolve(root, 'fixtures/features/file-list/files-to-check-missing.txt');
const configSamples = path.resolve(samples, 'config');

Expand Down Expand Up @@ -72,6 +74,7 @@ describe('Linter Validation Tests', () => {
${[]} | ${{ ...optionsRootCSpellJson, files: ['README.md', 'missing.txt'], dot: true, mustFindFiles: true }} | ${oc({ errors: 1, files: 2 })} | ${oc({ errorCount: 1, errors: [expect.anything()], issues: [] })}
${[]} | ${{ ...optionsRootCSpellJson, files: ['../../README.md'], dot: true }} | ${oc({ errors: 0, files: 1 })} | ${oc({ errorCount: 0, errors: [], issues: [] })}
${[]} | ${{ ...optionsRootCSpellJson, files: ['../../resources/patreon.png' /* skip binary */], dot: true }} | ${oc({ errors: 0, files: 0 })} | ${oc({ errorCount: 0, errors: [], issues: [] })}
${['**/*.md']} | ${{ root: './fixtures/issue-6025', config: './fixtures/issue-6025/nested/cspell.config.yaml' }} | ${oc({ errors: 0, files: 2 })} | ${oc({ errorCount: 0, errors: [], issues: [] })}
`('runLint $files $options', async ({ files, options, expectedRunResult, expectedReport }) => {
const reporter = new InMemoryReporter();
const runResult = await runLint(new LintRequest(files, options, reporter));
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/src/app/lint/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export async function runLint(cfg: LintRequest): Promise<RunResult> {

async function run(): Promise<RunResult> {
if (cfg.options.root) {
setEnvironmentVariable(ENV_CSPELL_GLOB_ROOT, cfg.options.root);
setEnvironmentVariable(ENV_CSPELL_GLOB_ROOT, cfg.root);
}

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

0 comments on commit 076362b

Please sign in to comment.