Skip to content

Commit

Permalink
Update to globby v12 (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Jul 22, 2021
1 parent f2b3321 commit e2be678
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
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"
}
}

0 comments on commit e2be678

Please sign in to comment.