Skip to content

Commit 377e343

Browse files
committed
chore: change globby library to glob
Closes conventional-changelog#2370
1 parent df52102 commit 377e343

File tree

9 files changed

+25
-28
lines changed

9 files changed

+25
-28
lines changed

@commitlint/config-lerna-scopes/index.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
const glob = require('glob');
12
const Path = require('path');
23
const importFrom = require('import-from');
34
const resolvePkg = require('resolve-pkg');
4-
const Globby = require('globby');
55
const semver = require('semver');
66

77
module.exports = {
@@ -21,14 +21,13 @@ function getPackages(context) {
2121
const {workspaces} = require(Path.join(cwd, 'package.json'));
2222
if (Array.isArray(workspaces) && workspaces.length) {
2323
// use yarn workspaces
24-
return Globby(
25-
workspaces.map((ws) => {
26-
return Path.posix.join(ws, 'package.json');
27-
}),
28-
{cwd, ignore: ['**/node_modules/**']}
29-
).then((pJsons = []) => {
30-
return pJsons.map((pJson) => require(Path.join(cwd, pJson)));
24+
25+
const wsGlobs = workspaces.flatMap((ws) => {
26+
const path = Path.posix.join(ws, 'package.json');
27+
return glob.sync(path, {cwd, ignore: ['**/node_modules/**']});
3128
});
29+
30+
return wsGlobs.map((pJson) => require(Path.join(cwd, pJson)));
3231
}
3332

3433
const lernaVersion = getLernaVersion(cwd);

@commitlint/config-lerna-scopes/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"node": ">=v14"
3939
},
4040
"dependencies": {
41-
"globby": "^11.0.1",
41+
"glob": "^8.0.3",
4242
"import-from": "4.0.0",
4343
"resolve-pkg": "2.0.0",
4444
"semver": "7.3.7"

@commitlint/config-patternplate/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
const glob = require('glob');
12
const path = require('path');
2-
const globby = require('globby');
33
const merge = require('lodash.merge');
44

55
function pathToId(root, filePath) {
@@ -9,10 +9,8 @@ function pathToId(root, filePath) {
99

1010
function getPatternIDs() {
1111
const root = path.resolve(process.cwd(), './patterns');
12-
const glob = path.resolve(root, '**/pattern.json');
13-
return globby(glob).then((results) =>
14-
results.map((result) => pathToId(root, result))
15-
);
12+
const pattern = path.resolve(root, '**/pattern.json');
13+
return glob.sync(pattern).map((result) => pathToId(root, result));
1614
}
1715

1816
module.exports = merge(require('@commitlint/config-angular'), {

@commitlint/config-patternplate/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"dependencies": {
3333
"@commitlint/config-angular": "^17.3.0",
34-
"globby": "^11.0.0",
34+
"glob": "^8.0.3",
3535
"lodash.merge": "^4.6.2"
3636
},
3737
"devDependencies": {

@commitlint/ensure/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@types/lodash.snakecase": "^4.1.7",
4242
"@types/lodash.startcase": "^4.4.7",
4343
"@types/lodash.upperfirst": "^4.3.7",
44-
"globby": "^11.0.0"
44+
"glob": "^8.0.3"
4545
},
4646
"dependencies": {
4747
"@commitlint/types": "^17.0.0",

@commitlint/ensure/src/index.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import path from 'path';
2-
import globby from 'globby';
2+
import glob from 'glob';
33
import camelCase from 'lodash.camelcase';
44
import * as ensure from '.';
55

66
test('exports all checkers', async () => {
77
const ignore = ['types'];
8-
const expected = (await glob('*.ts'))
8+
const expected = _glob('*.ts')
99
.map((f) => camelCase(f))
1010
.sort()
1111
.filter((item) => !ignore.includes(item));
@@ -18,8 +18,8 @@ test('rules export functions', () => {
1818
expect(actual.every((rule) => typeof rule === 'function')).toBe(true);
1919
});
2020

21-
async function glob(pattern: string): Promise<string[]> {
22-
const files = await globby(pattern, {
21+
function _glob(pattern: string): string[] {
22+
const files = glob.sync(pattern, {
2323
ignore: ['**/index.ts', '**/*.test.ts'],
2424
cwd: __dirname,
2525
});

@commitlint/rules/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@commitlint/test": "^17.2.0",
4040
"@commitlint/utils": "^17.0.0",
4141
"conventional-changelog-angular": "5.0.13",
42-
"globby": "^11.0.0"
42+
"glob": "^8.0.3"
4343
},
4444
"dependencies": {
4545
"@commitlint/ensure": "^17.3.0",

@commitlint/rules/src/index.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import path from 'path';
22
import fs from 'fs';
3-
import globby from 'globby';
3+
import glob from 'glob';
44
import rules from '.';
55

6-
test('exports all rules', async () => {
7-
const expected = (await glob('*.ts')).sort();
6+
test('exports all rules', () => {
7+
const expected = _glob('*.ts').sort();
88
const actual = Object.keys(rules).sort();
99
expect(actual).toEqual(expected);
1010
});
@@ -27,8 +27,8 @@ test('all rules are present in documentation', () => {
2727
expect(Object.keys(rules)).toEqual(expect.arrayContaining(results));
2828
});
2929

30-
async function glob(pattern: string | string[]) {
31-
const files = await globby(pattern, {
30+
function _glob(pattern: string) {
31+
const files = glob.sync(pattern, {
3232
ignore: ['**/index.ts', '**/*.test.ts'],
3333
cwd: __dirname,
3434
});

yarn.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -6155,7 +6155,7 @@ [email protected], glob@^7.1.3, glob@^7.1.4:
61556155
once "^1.3.0"
61566156
path-is-absolute "^1.0.0"
61576157

6158-
glob@^8.0.1:
6158+
glob@^8.0.1, glob@^8.0.3:
61596159
version "8.0.3"
61606160
resolved "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz#415c6eb2deed9e502c68fa44a272e6da6eeca42e"
61616161
integrity sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==
@@ -6212,7 +6212,7 @@ globals@^13.15.0:
62126212
dependencies:
62136213
type-fest "^0.20.2"
62146214

6215-
globby@^11.0.0, globby@^11.0.1, globby@^11.0.2, globby@^11.1.0:
6215+
globby@^11.0.1, globby@^11.0.2, globby@^11.1.0:
62166216
version "11.1.0"
62176217
resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
62186218
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==

0 commit comments

Comments
 (0)