diff --git a/README.md b/README.md index 1ed0a4be70..aad5a3f4e0 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,12 @@ let packages = await globby(['package.json', 'packages/*/package.json']) let pictures = globby.globbySync('content/*.(jpg|png)') ``` +Also, globby available via the `glob` shortcut: + +```js +await $`svgo ${await glob('*.svg')}` +``` + #### `os` package The [os](https://nodejs.org/api/os.html) package. diff --git a/index.d.ts b/index.d.ts index 94a40f8f20..f491d8af4a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -63,6 +63,7 @@ export const chalk: typeof _chalk export const fetch: typeof _fetch export const fs: typeof _fs export const globby: typeof _globby.globby & typeof _globby +export const glob: typeof _globby.globby & typeof _globby export const nothrow: nothrow export const os: typeof _os export const question: question @@ -77,6 +78,7 @@ declare global { var fetch: typeof _fetch var fs: typeof _fs var globby: typeof _globby.globby & typeof _globby + var glob: typeof _globby.globby & typeof _globby var nothrow: nothrow var os: typeof _os var question: question diff --git a/index.mjs b/index.mjs index 4b4d18702b..e082f2a839 100644 --- a/index.mjs +++ b/index.mjs @@ -31,6 +31,8 @@ export const globby = Object.assign(function globby(...args) { return globbyModule.globby(...args) }, globbyModule) +export const glob = globby + export function $(pieces, ...args) { let {verbose, cwd, shell, prefix} = $ let __from = (new Error().stack.split(/^\s*at\s/m)[2]).trim() @@ -341,6 +343,7 @@ Object.assign(global, { chalk, fetch, fs, + glob, globby, nothrow, os, diff --git a/test.mjs b/test.mjs index b1109b521d..25e3253b1a 100755 --- a/test.mjs +++ b/test.mjs @@ -14,6 +14,7 @@ import {strict as assert, deepEqual} from 'assert' import path from 'path' +import {glob} from './index.mjs' { // Only stdout is used during command substitution let hello = await $`echo Error >&2; echo Hello` @@ -160,6 +161,7 @@ import path from 'path' } { // globby available + assert(globby === glob) assert(typeof globby === 'function') assert(typeof globby.globbySync === 'function') assert(typeof globby.globbyStream === 'function')