Skip to content

Commit 3f97864

Browse files
committed
add a fixed version of expandGlob
1 parent 68bbf87 commit 3f97864

File tree

7 files changed

+49
-6
lines changed

7 files changed

+49
-6
lines changed

src/core/deno/expand-glob.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* expand-glob.ts
3+
*
4+
* Copyright (C) 2023 Posit Software, PBC
5+
*
6+
* Fixed version of expandGlob, expandGlobSync (https://github.com/denoland/deno_std/issues/3099)
7+
*
8+
*/
9+
10+
import {
11+
expandGlob as badExpandGlob,
12+
ExpandGlobOptions,
13+
expandGlobSync as badExpandGlobSync,
14+
} from "fs/mod.ts";
15+
16+
export function expandGlobSync(
17+
glob: string,
18+
options?: ExpandGlobOptions,
19+
): ReturnType<typeof badExpandGlobSync> {
20+
if (options === undefined) {
21+
return badExpandGlobSync(glob, { globstar: true });
22+
} else {
23+
return badExpandGlobSync(glob, {
24+
...options,
25+
globstar: options.globstar ?? true,
26+
});
27+
}
28+
}
29+
30+
export function expandGlob(
31+
glob: string,
32+
options?: ExpandGlobOptions,
33+
): ReturnType<typeof badExpandGlob> {
34+
if (options === undefined) {
35+
return badExpandGlob(glob, { globstar: true });
36+
} else {
37+
return badExpandGlob(glob, {
38+
...options,
39+
globstar: options.globstar ?? true,
40+
});
41+
}
42+
}

src/core/schema/yaml-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { YAMLSchema } from "../lib/yaml-validation/yaml-schema.ts";
1212
import { MappedString } from "../lib/text-types.ts";
1313
import { readAnnotatedYamlFromMappedString } from "./annotated-yaml.ts";
1414
import { loadDefaultSchemaDefinitions } from "../lib/yaml-schema/definitions.ts";
15-
import { expandGlobSync } from "fs/mod.ts";
15+
import { expandGlobSync } from "../deno/expand-glob.ts";
1616
import { resourcePath } from "../resources.ts";
1717
import { readYaml } from "../yaml.ts";
1818
import { JSONValue } from "../lib/yaml-schema/types.ts";

src/extension/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*
66
*/
77

8-
import { existsSync, expandGlobSync, walkSync } from "fs/mod.ts";
8+
import { existsSync, walkSync } from "fs/mod.ts";
9+
import { expandGlobSync } from "../core/deno/expand-glob.ts";
910
import { warning } from "log/mod.ts";
1011
import { coerce, Range, satisfies } from "semver/mod.ts";
1112

tests/integration/playwright-tests.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*/
77

8-
import { expandGlobSync } from "fs/mod.ts";
8+
import { expandGlobSync } from "../../src/core/deno/expand-glob.ts";
99
import { initYamlIntelligenceResourcesFromFilesystem } from "../../src/core/schema/utils.ts";
1010
import {
1111
initState,

tests/smoke/smoke-all.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*/
77

8-
import { expandGlobSync } from "fs/mod.ts";
8+
import { expandGlobSync } from "../../src/core/deno/expand-glob.ts";
99
import { testQuartoCmd, Verify } from "../test.ts";
1010

1111
import { initYamlIntelligenceResourcesFromFilesystem } from "../../src/core/schema/utils.ts";

tests/smoke/yaml-intelligence/yaml-intelligence.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*/
77

8-
import { expandGlobSync } from "fs/mod.ts";
8+
import { expandGlobSync } from "../../../src/core/deno/expand-glob.ts";
99
import { unitTest } from "../../test.ts";
1010

1111
import { assert, assertEquals } from "testing/asserts.ts";

tests/unit/schema-validation/schema-schema.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
refSchema,
1616
} from "../../../src/core/lib/yaml-schema/common.ts";
1717
import { readAndValidateYamlFromFile } from "../../../src/core/schema/validated-yaml.ts";
18-
import { expandGlobSync } from "fs/expand_glob.ts";
18+
import { expandGlobSync } from "../../../src/core/deno/expand-glob.ts";
1919
import { readAndValidateYamlFromMappedString } from "../../../src/core/lib/yaml-schema/validated-yaml.ts";
2020
import { asMappedString } from "../../../src/core/lib/mapped-text.ts";
2121

0 commit comments

Comments
 (0)