Commit c7c4835

Anton Medvedev <anton@medv.io>
2021-08-19 22:41:55
Add glob shortcut
1 parent 55037b3
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
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,
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.
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')