Skip to content

Commit b519a8b

Browse files
authored
Merge pull request #3407 from AJIb63PT/v7
migrate glob v7 to v11
2 parents f5dbf03 + f59d12a commit b519a8b

38 files changed

+2937
-1078
lines changed

.github/workflows/pull-request.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v3
1111

12-
- uses: actions/setup-node@v1
12+
- uses: actions/setup-node@v4
1313
with:
14-
node-version: 18.x
14+
node-version-file: '.nvmrc'
1515

1616
- name: Get npm cache directory
1717
id: npm-cache
@@ -37,9 +37,9 @@ jobs:
3737
steps:
3838
- uses: actions/checkout@v3
3939

40-
- uses: actions/setup-node@v1
40+
- uses: actions/setup-node@v4
4141
with:
42-
node-version: 18.x
42+
node-version-file: '.nvmrc'
4343

4444
- uses: actions/cache@v3
4545
with:

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
20

gulp-tasks/test-integration.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
const clearModule = require('clear-module');
1010
const execa = require('execa');
11-
const glob = require('glob');
11+
const {globSync} = require('glob');
1212
const ol = require('common-tags').oneLine;
1313
const upath = require('upath');
1414
const seleniumAssistant = require('selenium-assistant');
@@ -63,7 +63,7 @@ async function runTestSuite(testPath, nodeEnv, seleniumBrowser, webdriver) {
6363
webdriver,
6464
};
6565

66-
const testFiles = glob.sync(
66+
const testFiles = globSync(
6767
upath.join(__dirname, '..', testPath, 'test-*.js'),
6868
);
6969

@@ -74,7 +74,7 @@ async function runTestSuite(testPath, nodeEnv, seleniumBrowser, webdriver) {
7474
}
7575

7676
async function runIntegrationForBrowser(browser) {
77-
const packagesToTest = glob.sync(`test/${global.packageOrStar}/integration`);
77+
const packagesToTest = globSync(`test/${global.packageOrStar}/integration`);
7878

7979
for (const buildKey of Object.keys(constants.BUILD_TYPES)) {
8080
const webdriver = await browser.getSeleniumDriver();
@@ -121,7 +121,7 @@ async function test_integration() {
121121
await seleniumAssistant.downloadLocalBrowser('chrome', 'stable', expiration);
122122
await seleniumAssistant.downloadLocalBrowser('firefox', 'stable', expiration);
123123

124-
const packagesToTest = glob.sync(`test/${global.packageOrStar}/integration`);
124+
const packagesToTest = globSync(`test/${global.packageOrStar}/integration`);
125125
if (packagesToTest.length === 0) {
126126
return;
127127
}

gulp-tasks/test-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
const {series} = require('gulp');
1010
const execa = require('execa');
1111
const fse = require('fs-extra');
12-
const glob = require('glob');
12+
const {globSync} = require('glob');
1313
const ol = require('common-tags').oneLine;
1414
const upath = require('upath');
1515

@@ -58,7 +58,7 @@ async function runNodeTestsWithEnv(testGroup, nodeEnv) {
5858
globConfig.ignore = [];
5959
}
6060

61-
const packagesToTest = glob.sync(`test/${testGroup}/node`, globConfig);
61+
const packagesToTest = globSync(`test/${testGroup}/node`, globConfig);
6262
for (const packageToTest of packagesToTest) {
6363
// Hardcode special logic for webpack v4 and v5 tests, which need to
6464
// be run in separate processes.

gulp-tasks/utils/analyse-properties.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* This is very rough and vague. It needs to be run manually and if it's not
2020
* used can and should be removed from Workbox repo.
2121
*/
22-
const glob = require('glob');
22+
const {globSync} = require('glob');
2323
const path = require('path');
2424
const fs = require('fs-extra');
2525
const babylon = require('babylon');
@@ -54,7 +54,7 @@ class AnalyseBuildForProperties {
5454
constants.PACKAGE_BUILD_DIRNAME,
5555
'{*.prod.js,workbox-sw.js}',
5656
);
57-
return glob.sync(buildGlob);
57+
return globSync(buildGlob);
5858
}
5959

6060
analyzeFile(filePath) {

gulp-tasks/utils/cdn-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
https://opensource.org/licenses/MIT.
77
*/
88

9-
const glob = require('glob');
9+
const {globSync} = require('glob');
1010
const path = require('path');
1111
const {Storage} = require('@google-cloud/storage');
1212

@@ -56,7 +56,7 @@ class CDNHelper {
5656
async upload(tagName, directoryToUpload) {
5757
const gcs = await this.getGCS();
5858

59-
const filePaths = glob.sync(`${directoryToUpload}/*`, {
59+
const filePaths = globSync(`${directoryToUpload}/*`, {
6060
absolute: true,
6161
});
6262

gulp-tasks/utils/get-packages.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
https://opensource.org/licenses/MIT.
77
*/
88

9-
const glob = require('glob');
9+
const {globSync} = require('glob');
1010
const path = require('path');
1111

1212
const DEFAULT_ROOT = path.join(__dirname, '..', '..');
1313

1414
const getPackages = ({type, root = DEFAULT_ROOT} = {}) => {
15-
const pathToPkgJsons = glob.sync('packages/*/package.json', {cwd: root});
15+
const pathToPkgJsons = globSync('packages/*/package.json', {cwd: root});
1616

1717
return pathToPkgJsons
1818
.map((pathToPkgJson) => {

gulp-tasks/utils/package-runner.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
*/
88

99
const path = require('path');
10-
const glob = require('glob');
10+
const {globSync} = require('glob');
11+
1112
const oneLine = require('common-tags').oneLine;
1213

1314
const pkgPathToName = require('./pkg-path-to-name');
@@ -18,20 +19,18 @@ const pkgPathToName = require('./pkg-path-to-name');
1819
* @return Array<string> Paths to package.json files for the matching packages.
1920
*/
2021
function getPackages(typeFilter) {
21-
return glob
22-
.sync(`packages/${global.packageOrStar}/package.json`, {
23-
absolute: true,
24-
})
25-
.filter((pathToPackageJson) => {
26-
const pkgInfo = require(pathToPackageJson);
27-
const packageType = pkgInfo.workbox.packageType;
28-
if (!packageType) {
29-
throw Error(oneLine`Unable to determine package type. Please add
22+
return globSync(`packages/${global.packageOrStar}/package.json`, {
23+
absolute: true,
24+
}).filter((pathToPackageJson) => {
25+
const pkgInfo = require(pathToPackageJson);
26+
const packageType = pkgInfo.workbox.packageType;
27+
if (!packageType) {
28+
throw Error(oneLine`Unable to determine package type. Please add
3029
workbox.packageType metadata to ${pathToPackageJson}`);
31-
}
30+
}
3231

33-
return typeFilter === 'all' || typeFilter === packageType;
34-
});
32+
return typeFilter === 'all' || typeFilter === packageType;
33+
});
3534
}
3635

3736
/*

gulp-tasks/utils/publish-helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
const execa = require('execa');
1010
const fse = require('fs-extra');
11-
const glob = require('glob');
11+
const {globSync} = require('glob');
1212
const ol = require('common-tags').oneLine;
1313
const upath = require('upath');
1414

@@ -126,7 +126,7 @@ const groupBuildFiles = async (tagName, gitBranch) => {
126126

127127
// Copy files from the source code and move into the grouped build
128128
// directory. In others, have a flat file structure of just the built files.
129-
const filesToInclude = glob.sync(pattern);
129+
const filesToInclude = globSync(pattern);
130130
for (const fileToInclude of filesToInclude) {
131131
await fse.copy(
132132
fileToInclude,

0 commit comments

Comments
 (0)