-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathglob.ts
More file actions
41 lines (38 loc) · 1.21 KB
/
glob.ts
File metadata and controls
41 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {Globber, DefaultGlobber} from './internal-globber.js'
import {GlobOptions} from './internal-glob-options.js'
import {HashFileOptions} from './internal-hash-file-options.js'
import {hashFiles as _hashFiles} from './internal-hash-files.js'
export {Globber, GlobOptions}
/**
* Constructs a globber
*
* @param patterns Patterns separated by newlines
* @param options Glob options
*/
export async function create(
patterns: string,
options?: GlobOptions
): Promise<Globber> {
return await DefaultGlobber.create(patterns, options)
}
/**
* Computes the sha256 hash of a glob
*
* @param patterns Patterns separated by newlines
* @param currentWorkspace Workspace used when matching files
* @param options Glob options
* @param verbose Enables verbose logging
*/
export async function hashFiles(
patterns: string,
currentWorkspace = '',
options?: HashFileOptions,
verbose: Boolean = false
): Promise<string> {
let followSymbolicLinks = true
if (options && typeof options.followSymbolicLinks === 'boolean') {
followSymbolicLinks = options.followSymbolicLinks
}
const globber = await create(patterns, {followSymbolicLinks})
return _hashFiles(globber, currentWorkspace, options, verbose)
}