Skip to content

Commit

Permalink
Add glob shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Aug 19, 2021
1 parent 55037b3 commit c7c4835
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -341,6 +343,7 @@ Object.assign(global, {
chalk,
fetch,
fs,
glob,
globby,
nothrow,
os,
Expand Down
2 changes: 2 additions & 0 deletions test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit c7c4835

Please sign in to comment.