Skip to content

Commit

Permalink
move away from default-export modules
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 9, 2023
1 parent 760ad8b commit 26673b9
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 58 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ const {
Glob,
} = require('glob')

// or default export is fine too, just returns the glob function
// with all the aliases attached.
import glob from 'glob'
// or using commonjs
const glob = require('glob')

// the main glob() and globSync() resolve/return array of filenames

// all js files, but don't look in node_modules
Expand Down
2 changes: 1 addition & 1 deletion benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ MJS

echo -n $'node current glob async mjs \t'
cat > "$wd/bench-working-dir/async.mjs" <<MJS
import glob from '$wd/dist/mjs/index.js'
import { glob } from '$wd/dist/mjs/index.js'
glob(process.argv[2]).then(files => console.log(files.length))
MJS
t node "$wd/bench-working-dir/async.mjs" "$p"
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# changeglob

## 10.0.0

- No default exports, only named exports

## 9.3.3

- Upgraded minimatch to v8, adding support for any degree of
Expand Down
47 changes: 28 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "git://github.com/isaacs/node-glob.git"
},
"main": "./dist/cjs/index-cjs.js",
"main": "./dist/cjs/index.js",
"module": "./dist/mjs/index.js",
"types": "./dist/mjs/index.d.ts",
"exports": {
Expand All @@ -18,7 +18,7 @@
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index-cjs.js"
"default": "./dist/cjs/index.js"
}
}
},
Expand Down Expand Up @@ -60,9 +60,9 @@
},
"dependencies": {
"fs.realpath": "^1.0.0",
"minimatch": "^8.0.2",
"minipass": "^4.2.4",
"path-scurry": "^1.6.1"
"minimatch": "^9.0.0",
"minipass": "^5.0.0",
"path-scurry": "^1.6.4"
},
"devDependencies": {
"@types/node": "^18.11.18",
Expand Down
2 changes: 1 addition & 1 deletion prof.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd "$tmp"
export __GLOB_PROFILE__=1

cat > "profscript.mjs" <<MJS
import glob from '$wd/dist/mjs/index.js'
import { glob } from '$wd/dist/mjs/index.js'
const patterns = process.argv.slice(2)
for (const p of patterns) {
glob.sync("./fixture/" + p)
Expand Down
2 changes: 1 addition & 1 deletion src/glob.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Minimatch, MinimatchOptions } from 'minimatch'
import Minipass from 'minipass'
import { Minipass } from 'minipass'
import {
FSOption,
Path,
Expand Down
3 changes: 0 additions & 3 deletions src/index-cjs.ts

This file was deleted.

17 changes: 9 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { escape, unescape } from 'minimatch'
import Minipass from 'minipass'
import { Minipass } from 'minipass'
import { Path } from 'path-scurry'
import type {
GlobOptions,
Expand Down Expand Up @@ -97,23 +97,23 @@ export function globSync(
* {@link withFileTypes} option is set to `true`. See {@link GlobOptions} for
* full option descriptions.
*/
export async function glob(
async function glob_(
pattern: string | string[],
options?: GlobOptionsWithFileTypesUnset | undefined
): Promise<string[]>
export async function glob(
async function glob_(
pattern: string | string[],
options: GlobOptionsWithFileTypesTrue
): Promise<Path[]>
export async function glob(
async function glob_(
pattern: string | string[],
options: GlobOptionsWithFileTypesFalse
): Promise<string[]>
export async function glob(
async function glob_(
pattern: string | string[],
options: GlobOptions
): Promise<Path[] | string[]>
export async function glob(
async function glob_(
pattern: string | string[],
options: GlobOptions = {}
) {
Expand Down Expand Up @@ -198,8 +198,8 @@ export type { IgnoreLike } from './ignore.js'
export type { MatchStream } from './walker.js'
/* c8 ignore stop */

export default Object.assign(glob, {
glob,
export const glob = Object.assign(glob_, {
glob: glob_,
globSync,
sync,
globStream,
Expand All @@ -215,3 +215,4 @@ export default Object.assign(glob, {
escape,
unescape,
})
glob.glob = glob
2 changes: 1 addition & 1 deletion src/walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @module
*/
import Minipass from 'minipass'
import { Minipass } from 'minipass'
import { Path } from 'path-scurry'
import { Ignore, IgnoreLike } from './ignore.js'

Expand Down
2 changes: 1 addition & 1 deletion test/bash-comparison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// show that it does the same thing by default as the shell.
import { resolve } from 'path'
import t from 'tap'
import glob from '../'
import { glob } from '../'
import { bashResults } from './bash-results'
const globs = Object.keys(bashResults)

Expand Down
2 changes: 1 addition & 1 deletion test/broken-symlink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { relative } from 'path'
import t from 'tap'
import glob from '../'
import { glob } from '../'
import { GlobOptionsWithFileTypesUnset } from '../src/glob.js'

if (process.platform === 'win32') {
Expand Down
2 changes: 1 addition & 1 deletion test/follow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import t from 'tap'
import glob from '../'
import { glob } from '../'

if (process.platform === 'win32') {
t.plan(0, 'skip on windows')
Expand Down
2 changes: 1 addition & 1 deletion test/has-magic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import t from 'tap'
import glob from '../'
import { glob } from '../'
process.chdir(__dirname)

t.test('non-string pattern is evil magic', async t => {
Expand Down
2 changes: 1 addition & 1 deletion test/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Show that glob ignores results matching pattern on ignore option

import t from 'tap'
import glob from '../'
import { glob } from '../'
import type { GlobOptions } from '../src/index.js'

import { sep } from 'path'
Expand Down
2 changes: 1 addition & 1 deletion test/mark.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import t from 'tap'
import glob from '../'
import { glob } from '../'
process.chdir(__dirname + '/fixtures')

const alphasort = (a: string, b: string) => a.localeCompare(b, 'en')
Expand Down
2 changes: 1 addition & 1 deletion test/match-base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import t from 'tap'
import glob from '../'
import { glob } from '../'

import { resolve } from 'path'
import { sep } from 'path'
Expand Down
2 changes: 1 addition & 1 deletion test/nodir.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve, sep } from 'path'
import t from 'tap'
import glob from '../'
import { glob } from '../'
import type { GlobOptions } from '../src/index.js'
process.chdir(__dirname + '/fixtures')

Expand Down
2 changes: 1 addition & 1 deletion test/readme-issue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import t from 'tap'
import glob from '../'
import { glob } from '../'

const dir = t.testdir({
'package.json': '{}',
Expand Down
2 changes: 1 addition & 1 deletion test/realpath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs'
import * as fsp from 'fs/promises'
import { resolve } from 'path'
import t from 'tap'
import glob from '../'
import { glob } from '../'
import { GlobOptionsWithFileTypesUnset } from '../src/glob'

const alphasort = (a: string, b: string) => a.localeCompare(b, 'en')
Expand Down
2 changes: 1 addition & 1 deletion test/slash-cwd.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// regression test to make sure that slash-ended patterns
// don't match files when using a different cwd.
import t from 'tap'
import glob from '../'
import { glob } from '../'
import type { GlobOptions } from '../src/index.js'

const pattern = '../{*.md,test}/'
Expand Down
2 changes: 1 addition & 1 deletion test/windows-paths-fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// when found in patterns and paths containing glob magic.

import t from 'tap'
import glob from '../'
import { glob } from '../'

const dir = t.testdir({
// treat escapes as path separators
Expand Down
1 change: 0 additions & 1 deletion tsconfig-esm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"extends": "./tsconfig-base.json",
"exclude": ["./test", "./tap-snapshots", "src/index-cjs.ts"],
"compilerOptions": {
"module": "esnext",
"outDir": "dist/mjs"
Expand Down

0 comments on commit 26673b9

Please sign in to comment.