Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace glob with tinyglobby #311

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module.exports = {
rules: {
'n/no-process-exit': 'off',
'n/no-missing-require': 'off', // `require` of `elm.json`.
'n/no-extraneous-require': ['error', {allowModules: ['fs-extra']}],
lishaduck marked this conversation as resolved.
Show resolved Hide resolved
'@typescript-eslint/ban-ts-comment': 'off' // `require` of `elm.json`.
}
},
Expand Down
3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ updates:
- dependency-name: 'eslint-plugin-unicorn'
update-types:
- version-update:semver-major
- dependency-name: 'glob'
update-types:
- version-update:semver-major
- dependency-name: 'which'
update-types:
- version-update:semver-major
Expand Down
10 changes: 5 additions & 5 deletions lib/elm-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
const path = require('node:path');
const chalk = require('chalk');
const {glob} = require('glob');
const {glob} = require('tinyglobby');
const Anonymize = require('./anonymize');
const Benchmark = require('./benchmark');
const Cache = require('./cache');
Expand Down Expand Up @@ -308,9 +308,9 @@ async function findForCliArguments(directory, path_) {
// For finding files when `directory` is a direct Elm file, like "src/File.elm"
return {
files: await glob(path_, {
nocase: true,
caseSensitiveMatch: false,
ignore: globIgnore,
nodir: true
onlyFiles: false
}),
directory
};
Expand Down Expand Up @@ -342,9 +342,9 @@ async function findForCliArguments(directory, path_) {
async function findFromFolder(directory, path_) {
return {
files: await glob(`${path_}/**/*.elm`, {
nocase: true,
caseSensitiveMatch: false,
ignore: globIgnore,
nodir: false
onlyFiles: false
}),
directory
};
Expand Down
4 changes: 2 additions & 2 deletions lib/new-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ function packageJson(options, packageName) {
'elm-test': '^0.19.1-revision10',
'elm-tooling': '^1.13.1',
'fs-extra': '^9.0.0',
glob: '^9.3.1',
'npm-run-all': '^4.1.5'
'npm-run-all': '^4.1.5',
tinyglobby: '^0.2.10'
}
};
}
Expand Down
8 changes: 4 additions & 4 deletions lib/new-rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*/
const path = require('node:path');
const chalk = require('chalk');
const {glob} = require('glob');
const fs = require('graceful-fs');
const prompts = require('prompts');
const {globSync} = require('tinyglobby');
const ErrorMessage = require('./error-message');
const FS = require('./fs-wrapper');
const OsHelpers = require('./os-helpers');
Expand Down Expand Up @@ -234,12 +234,12 @@ async function addRule(options, elmJson, ruleName, ruleType) {
}
}

const globbed = glob.sync(
const globbed = globSync(
OsHelpers.makePathOsAgnostic(`${dir}/preview*/**/elm.json`),
{
nocase: true,
caseSensitiveMatch: false,
ignore: ['**/elm-stuff/**'],
nodir: false
onlyFiles: false
}
);

Expand Down
6 changes: 3 additions & 3 deletions lib/suppressed-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const childProcess = require('node:child_process');
const path = require('node:path');
const chalk = require('chalk');
const {glob} = require('glob');
const {glob} = require('tinyglobby');
const exit = require('../vendor/exit');
const ErrorMessage = require('./error-message');
const FS = require('./fs-wrapper');
Expand Down Expand Up @@ -139,9 +139,9 @@ async function read(options) {
`${options.suppressedErrorsFolder()}/**/*.json`
);
let files = await glob(pattern, {
nocase: true,
caseSensitiveMatch: false,
ignore: ['**/elm-stuff/**'],
nodir: false
onlyFiles: false
});

if (options.rulesFilter) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('node:path');
const {glob} = require('glob');
const {globSync} = require('tinyglobby');

const root = path
.resolve(__dirname, '../../')
Expand All @@ -10,12 +10,10 @@ const root = path
* @returns {string[]}
*/
function findPreviewConfigurations() {
return glob
.sync(`${root}/preview*/**/elm.json`, {
ignore: ['**/elm-stuff/**'],
nodir: true
})
.map((val) => path.dirname(val));
return globSync(`${root}/preview*/**/elm.json`, {
ignore: ['**/elm-stuff/**'],
onlyFiles: false
}).map((val) => path.dirname(val));
}

module.exports = {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"fastest-levenshtein": "^1.0.16",
"find-up": "^4.1.0 || ^5.0.0",
"folder-hash": "^3.3.0",
"glob": "^10.2.6",
"got": "^11.8.5",
"graceful-fs": "^4.2.11",
"minimist": "^1.2.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('node:path');
const {glob} = require('glob');
const {globSync} = require('tinyglobby');

const root = path
.resolve(__dirname, '../../')
Expand All @@ -10,12 +10,10 @@ const root = path
* @returns {string[]}
*/
function findPreviewConfigurations() {
return glob
.sync(`${root}/preview*/**/elm.json`, {
ignore: ['**/elm-stuff/**'],
nodir: true
})
.map((val) => path.dirname(val));
return globSync(`${root}/preview*/**/elm.json`, {
ignore: ['**/elm-stuff/**'],
onlyFiles: false
}).map((val) => path.dirname(val));
}

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"elm-test": "^0.19.1-revision10",
"elm-tooling": "^1.13.1",
"fs-extra": "^9.0.0",
"glob": "^9.3.1",
"npm-run-all": "^4.1.5"
"npm-run-all": "^4.1.5",
"tinyglobby": "^0.2.10"
},
"license": "BSD-3-Clause"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('node:path');
const {glob} = require('glob');
const {globSync} = require('tinyglobby');

const root = path
.resolve(__dirname, '../../')
Expand All @@ -10,12 +10,10 @@ const root = path
* @returns {string[]}
*/
function findPreviewConfigurations() {
return glob
.sync(`${root}/preview*/**/elm.json`, {
ignore: ['**/elm-stuff/**'],
nodir: true
})
.map((val) => path.dirname(val));
return globSync(`${root}/preview*/**/elm.json`, {
ignore: ['**/elm-stuff/**'],
onlyFiles: false
}).map((val) => path.dirname(val));
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions test/run-snapshots/elm-review-something/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"elm-test": "^0.19.1-revision10",
"elm-tooling": "^1.13.1",
"fs-extra": "^9.0.0",
"glob": "^9.3.1",
"npm-run-all": "^4.1.5"
"npm-run-all": "^4.1.5",
"tinyglobby": "^0.2.10"
},
"license": "BSD-3-Clause"
}
Loading