Skip to content

Commit 68e415d

Browse files
committed
refactor: use external picomatch pattern for bundling
- Add TypeScript type definitions for picomatch in src/external/picomatch.d.ts - Update import in src/releases/github.ts from 'picomatch' to '../external/picomatch.js' - Ensure picomatch is properly bundled in dist/external/ directory - Maintain version 4.0.3 via pnpm override This change follows the established socket-lib pattern for bundling external dependencies, ensuring they are included in the distribution without requiring consumers to install them separately.
1 parent 1fe8998 commit 68e415d

2 files changed

Lines changed: 91 additions & 1 deletion

File tree

src/external/picomatch.d.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* Picomatch options for glob pattern matching.
3+
*/
4+
export interface PicomatchOptions {
5+
/**
6+
* When true, the glob will match the basename of the path.
7+
* @default false
8+
*/
9+
basename?: boolean
10+
11+
/**
12+
* When true, the glob will match case-insensitively.
13+
* @default false
14+
*/
15+
nocase?: boolean
16+
17+
/**
18+
* When true, allow matching dotfiles (files starting with '.').
19+
* @default false
20+
*/
21+
dot?: boolean
22+
23+
/**
24+
* Glob patterns to ignore.
25+
*/
26+
ignore?: string | string[]
27+
28+
/**
29+
* When true, a leading '!' will negate the glob.
30+
* @default true
31+
*/
32+
negate?: boolean
33+
34+
/**
35+
* When true, match against Windows paths.
36+
* Defaults to os.platform() === 'win32'.
37+
*/
38+
windows?: boolean
39+
40+
/**
41+
* When true, convert backslashes to forward slashes in paths.
42+
* @default true on Windows
43+
*/
44+
normalize?: boolean
45+
46+
/**
47+
* Function to call on each match result.
48+
*/
49+
onMatch?: (result: unknown) => void
50+
51+
/**
52+
* Function to call on each result.
53+
*/
54+
onResult?: (result: unknown) => void
55+
56+
/**
57+
* Format function for transforming paths.
58+
*/
59+
format?: (input: string) => string
60+
}
61+
62+
/**
63+
* Matcher function returned by picomatch.
64+
* Tests if a string matches the glob pattern.
65+
*/
66+
export type Matcher = (input: string) => boolean
67+
68+
/**
69+
* Creates a matcher function from a glob pattern.
70+
* The returned function takes a string to match as its argument.
71+
*
72+
* @param pattern - Glob pattern to match against
73+
* @param options - Picomatch options
74+
* @returns Matcher function that tests strings against the pattern
75+
*
76+
* @example
77+
* ```ts
78+
* import picomatch from './external/picomatch.js'
79+
*
80+
* const isMatch = picomatch('*.js')
81+
* isMatch('test.js') // true
82+
* isMatch('test.ts') // false
83+
* ```
84+
*/
85+
declare function picomatch(
86+
pattern: string | string[],
87+
options?: PicomatchOptions,
88+
): Matcher
89+
90+
export default picomatch

src/releases/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { chmodSync, existsSync } from 'fs'
66
import { readFile, writeFile } from 'fs/promises'
77

8-
import picomatch from 'picomatch'
8+
import picomatch from '../external/picomatch.js'
99

1010
import { safeMkdir } from '../fs.js'
1111
import { httpDownload, httpRequest } from '../http-request.js'

0 commit comments

Comments
 (0)