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

Update to globby v12 #87

Merged
Merged
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
10 changes: 5 additions & 5 deletions glob-pattern.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path';
import fs from 'node:fs';
import glob from 'globby';
import {globbySync, isDynamicPattern} from 'globby';
import junk from 'junk';

export default class GlobPattern {
Expand All @@ -16,7 +16,7 @@ export default class GlobPattern {
this.options = options;

if (
!glob.hasMagic(pattern)
!isDynamicPattern(pattern)
&& fs.existsSync(pattern)
&& fs.lstatSync(pattern).isDirectory()
) {
Expand All @@ -30,7 +30,7 @@ export default class GlobPattern {

get normalizedPath() {
const segments = this.originalPath.split('/');
const magicIndex = segments.findIndex(item => item ? glob.hasMagic(item) : false);
const magicIndex = segments.findIndex(item => item ? isDynamicPattern(item) : false);
const normalized = segments.slice(0, magicIndex).join('/');

if (normalized) {
Expand All @@ -41,11 +41,11 @@ export default class GlobPattern {
}

hasMagic() {
return glob.hasMagic(this.options.flat ? this.path : this.originalPath);
return isDynamicPattern(this.options.flat ? this.path : this.originalPath);
}

getMatches() {
let matches = glob.sync(this.path, {
let matches = globbySync(this.path, {
...this.options,
dot: true,
absolute: true,
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {GlobbyOptions as GlobOptions} from 'globby';
import {Options as GlobOptions} from 'globby';
import {Options as CpFileOptions} from 'cp-file';

export interface Entry {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import pMap from 'p-map';
import arrify from 'arrify';
import cpFile from 'cp-file';
import pFilter from 'p-filter';
import glob from 'globby';
import {isDynamicPattern} from 'globby';
import CpyError from './cpy-error.js';
import GlobPattern from './glob-pattern.js';

Expand Down Expand Up @@ -162,7 +162,7 @@ export default function cpy(
);
}

if (matches.length === 0 && !glob.hasMagic(pattern.originalPath)) {
if (matches.length === 0 && !isDynamicPattern(pattern.originalPath)) {
throw new CpyError(
`Cannot copy \`${pattern.originalPath}\`: the file doesn't exist`,
);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"dependencies": {
"arrify": "^3.0.0",
"cp-file": "^9.1.0",
"globby": "^11.0.4",
"globby": "^12.0.0",
"junk": "^3.1.0",
"nested-error-stacks": "^2.1.0",
"p-filter": "^2.1.0",
Expand All @@ -60,6 +60,6 @@
"tempy": "^1.0.1",
"tsd": "^0.17.0",
"typescript": "^4.3.5",
"xo": "^0.41.0"
"xo": "^0.42.0"
}
}