Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"expect": "^27.5.1",
"fast-glob": "^3.3.3",
"fetch-mock": "^9.11.0",
"file-entry-cache": "^6.0.1",
"husky": "^7.0.4",
Expand All @@ -126,6 +125,7 @@
"patch-package": "^6.4.7",
"prettier": "^2.4.1",
"semantic-release": "^19.0.5",
"tinyglobby": "^0.2.14",
"ts-jest": "^29.2.5",
"ts-node": "^10.8.2",
"typescript": "4.4.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"@stoplight/spectral-runtime": "^1.1.2",
"@stoplight/types": "^13.6.0",
"chalk": "4.1.2",
"fast-glob": "~3.2.12",
"hpagent": "~1.2.0",
"lodash": "~4.17.21",
"pony-cause": "^1.1.1",
"stacktracey": "^2.1.8",
"tinyglobby": "^0.2.14",
"tslib": "^2.8.1",
"yargs": "~17.7.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import * as path from '@stoplight/path';
import * as fg from 'fast-glob';
import { glob } from 'tinyglobby';
import { listFiles } from '../listFiles';

jest.mock('fast-glob', () => jest.fn(async () => []));
jest.mock('tinyglobby', () => ({
glob: jest.fn(async () => []),
}));

describe('listFiles CLI util', () => {
it('unixify paths', () => {
listFiles(['.\\repro\\lib.yaml', './foo/*.json', '.\\src\\__tests__\\__fixtures__\\*.oas.json'], true);
expect(fg).toBeCalledWith(['./repro/lib.yaml', './foo/*.json', './src/__tests__/__fixtures__/*.oas.json'], {
expect(glob).toBeCalledWith(['./repro/lib.yaml', './foo/*.json', './src/__tests__/__fixtures__/*.oas.json'], {
dot: true,
absolute: true,
});
Expand All @@ -16,15 +18,15 @@ describe('listFiles CLI util', () => {
it('returns file paths', async () => {
const list = [path.join(__dirname, 'foo/a.json'), path.join(__dirname, 'foo/b.json')];

(fg as unknown as jest.Mock).mockResolvedValueOnce([...list]);
(glob as unknown as jest.Mock).mockResolvedValueOnce([...list]);

expect(await listFiles(['./foo/*.json'], true)).toEqual([list, []]);
});

it('given disabled ignoredUnmatchedGlobs, reports unmatched patterns', async () => {
const list = [path.join(__dirname, 'foo/a.json'), path.join(__dirname, 'foo/b.json')];

(fg as unknown as jest.Mock).mockImplementation(async pattern => {
(glob as unknown as jest.Mock).mockImplementation(async pattern => {
if (pattern === './foo/*.json') {
return list;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/services/linter/utils/listFiles.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { normalize } from '@stoplight/path';
import fg from 'fast-glob';
import { glob } from 'tinyglobby';

const GLOB_OPTIONS = {
absolute: true,
dot: true,
};

async function match(pattern: fg.Pattern | fg.Pattern[]): Promise<string[]> {
return (await fg(pattern, GLOB_OPTIONS)).map(normalize);
async function match(pattern: string | string[]): Promise<string[]> {
return (await glob(pattern, GLOB_OPTIONS)).map(normalize);
}

const compareString = (a: string, b: string): number => a.localeCompare(b);
Expand Down
4 changes: 2 additions & 2 deletions packages/formatters/scripts/bundle-html-templates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import * as astring from 'astring';
import { builders as b } from 'ast-types';

import eol from 'eol';
import fg from 'fast-glob';
import { glob } from 'tinyglobby';

const cwd = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');

fg('src/html/*.html', { cwd, absolute: true })
glob('src/html/*.html', { cwd, absolute: true, expandDirectories: false })
.then(files =>
Promise.all(
files.map(async file => ({ file: path.basename(file), content: eol.lf(await fs.readFile(file, 'utf8')) })),
Expand Down
9 changes: 6 additions & 3 deletions test-harness/scripts/generate-tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from '@stoplight/path';
import * as swc from '@swc/core';
import fg from 'fast-glob';
import { glob } from 'tinyglobby';
import * as fileEntryCache from 'file-entry-cache';
import * as _fs from 'fs';

Expand Down Expand Up @@ -50,9 +50,12 @@ function getChangedScenarios(changedFiles: string[], scenarios: string[]): strin
(async () => {
await fs.mkdir(OUT_DIR, { recursive: true });

const scenarios = await fg('**/*.scenario', { cwd: SCENARIOS_DIR, absolute: true });
const scenarios = await glob('**/*.scenario', { cwd: SCENARIOS_DIR, absolute: true, expandDirectories: false });
const cache = fileEntryCache.create('spectral-test-harness', path.join(__dirname, '../../.cache'), true);
const changedFiles = cache.getUpdatedFiles([...scenarios, ...(await fg('**/**', { cwd: OUT_DIR, absolute: true }))]);
const changedFiles = cache.getUpdatedFiles([
...scenarios,
...(await glob('**/**', { cwd: OUT_DIR, absolute: true, expandDirectories: false })),
]);
const changedScenarios = getChangedScenarios(changedFiles, scenarios);

await Promise.all(
Expand Down
61 changes: 32 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2948,12 +2948,12 @@ __metadata:
"@yao-pkg/pkg": 5.11.0
chalk: 4.1.2
es-aggregate-error: ^1.0.7
fast-glob: ~3.2.12
hpagent: ~1.2.0
lodash: ~4.17.21
nock: ^13.5.4
pony-cause: ^1.1.1
stacktracey: ^2.1.8
tinyglobby: ^0.2.14
tslib: ^2.8.1
xml2js: ^0.5.0
yargs: ~17.7.2
Expand Down Expand Up @@ -6896,32 +6896,6 @@ __metadata:
languageName: node
linkType: hard

"fast-glob@npm:^3.3.3":
version: 3.3.3
resolution: "fast-glob@npm:3.3.3"
dependencies:
"@nodelib/fs.stat": ^2.0.2
"@nodelib/fs.walk": ^1.2.3
glob-parent: ^5.1.2
merge2: ^1.3.0
micromatch: ^4.0.8
checksum: 0704d7b85c0305fd2cef37777337dfa26230fdd072dce9fb5c82a4b03156f3ffb8ed3e636033e65d45d2a5805a4e475825369a27404c0307f2db0c8eb3366fbd
languageName: node
linkType: hard

"fast-glob@npm:~3.2.12":
version: 3.2.12
resolution: "fast-glob@npm:3.2.12"
dependencies:
"@nodelib/fs.stat": ^2.0.2
"@nodelib/fs.walk": ^1.2.3
glob-parent: ^5.1.2
merge2: ^1.3.0
micromatch: ^4.0.4
checksum: 0b1990f6ce831c7e28c4d505edcdaad8e27e88ab9fa65eedadb730438cfc7cde4910d6c975d6b7b8dc8a73da4773702ebcfcd6e3518e73938bb1383badfe01c2
languageName: node
linkType: hard

"fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.0.0":
version: 2.0.0
resolution: "fast-json-stable-stringify@npm:2.0.0"
Expand Down Expand Up @@ -6982,6 +6956,18 @@ __metadata:
languageName: node
linkType: hard

"fdir@npm:^6.4.4":
version: 6.4.6
resolution: "fdir@npm:6.4.6"
peerDependencies:
picomatch: ^3 || ^4
peerDependenciesMeta:
picomatch:
optional: true
checksum: fe9f3014901d023cf631831dcb9eae5447f4d7f69218001dd01ecf007eccc40f6c129a04411b5cc273a5f93c14e02e971e17270afc9022041c80be924091eb6f
languageName: node
linkType: hard

"fetch-mock@npm:^9.11.0":
version: 9.11.0
resolution: "fetch-mock@npm:9.11.0"
Expand Down Expand Up @@ -10066,7 +10052,7 @@ __metadata:
languageName: node
linkType: hard

"micromatch@npm:^4.0.0, micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:^4.0.8":
"micromatch@npm:^4.0.0, micromatch@npm:^4.0.2, micromatch@npm:^4.0.4":
version: 4.0.8
resolution: "micromatch@npm:4.0.8"
dependencies:
Expand Down Expand Up @@ -11466,6 +11452,13 @@ __metadata:
languageName: node
linkType: hard

"picomatch@npm:^4.0.2":
version: 4.0.2
resolution: "picomatch@npm:4.0.2"
checksum: a7a5188c954f82c6585720e9143297ccd0e35ad8072231608086ca950bee672d51b0ef676254af0788205e59bd4e4deb4e7708769226bed725bf13370a7d1464
languageName: node
linkType: hard

"pify@npm:^3.0.0":
version: 3.0.0
resolution: "pify@npm:3.0.0"
Expand Down Expand Up @@ -12297,7 +12290,6 @@ __metadata:
eslint-plugin-import: ^2.26.0
eslint-plugin-prettier: ^4.2.1
expect: ^27.5.1
fast-glob: ^3.3.3
fetch-mock: ^9.11.0
file-entry-cache: ^6.0.1
husky: ^7.0.4
Expand All @@ -12315,6 +12307,7 @@ __metadata:
patch-package: ^6.4.7
prettier: ^2.4.1
semantic-release: ^19.0.5
tinyglobby: ^0.2.14
ts-jest: ^29.2.5
ts-node: ^10.8.2
typescript: 4.4.4
Expand Down Expand Up @@ -13358,6 +13351,16 @@ __metadata:
languageName: node
linkType: hard

"tinyglobby@npm:^0.2.14":
version: 0.2.14
resolution: "tinyglobby@npm:0.2.14"
dependencies:
fdir: ^6.4.4
picomatch: ^4.0.2
checksum: 261e986e3f2062dec3a582303bad2ce31b4634b9348648b46828c000d464b012cf474e38f503312367d4117c3f2f18611992738fca684040758bba44c24de522
languageName: node
linkType: hard

"tmp@npm:^0.0.33":
version: 0.0.33
resolution: "tmp@npm:0.0.33"
Expand Down