@rust-gear/glob 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +23 -13
  2. package/index.d.ts +3 -3
  3. package/package.json +10 -10
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rust-glob
1
+ # @rust-gear/glob
2
2
 
3
3
  A high-performance globbing library for Node.js, powered by native Rust code.
4
4
 
@@ -13,41 +13,51 @@ npm install --save-dev @rust-gear/glob
13
13
  ```js
14
14
  import { globSync, glob } from "@rust-gear/glob";
15
15
 
16
- const files = globSync("src/**/*.rs", { cwd: process.cwd() });
16
+ const files = globSync("src/**/*.rs");
17
17
  console.log(files);
18
18
 
19
- const filesAsync = await glob("src/**/*.rs", { cwd: process.cwd() });
19
+ const filesAsync = await glob("src/**/*.rs");
20
20
  console.log(filesAsync);
21
21
  ```
22
22
 
23
23
  ## Options
24
24
 
25
- You must pass an options object as the second argument to `globSync`/`glob`.
26
- The `cwd` option is **required**.
25
+ You can pass an options object as the second argument to `globSync/glob`.
27
26
 
28
- > **Note:**
29
- > If you need to search an absolute path, set it as `cwd` and use a relative pattern.
27
+ > **Return path type:**
28
+ > If the pattern is absolute, absolute paths are returned.
29
+ > If the pattern is relative, paths are returned relative to the specified `cwd`.
30
30
 
31
- | Option | Type | Description |
32
- | :------ | :------- | :----------------------------------------------------- |
33
- | cwd | string | **(Required)** Current working directory for searching |
34
- | exclude | string[] | Array of glob patterns to exclude |
31
+ | Option | Type | Description |
32
+ | :------ | :------- | :-------------------------------------- |
33
+ | cwd | string | Current working directory for searching |
34
+ | exclude | string[] | Array of glob patterns to exclude |
35
35
 
36
36
  ### Example
37
37
 
38
38
  ```js
39
+ // Relative pattern, returns paths relative to cwd
39
40
  const files = globSync("**/*.rs", {
40
41
  cwd: "src",
41
42
  exclude: ["**/test/**", "**/target/**"],
42
43
  });
44
+
45
+ // Convert all relative paths to absolute paths
46
+ const absFiles = globSync("**/*.rs", {
47
+ cwd: "src",
48
+ exclude: ["**/test/**", "**/target/**"],
49
+ }).map((f) => path.resolve(cwd(), f));
50
+
51
+ // Absolute pattern, returns absolute paths
52
+ const absoluteFiles = globSync("/Users/foo/project/src/**/*.rs");
43
53
  ```
44
54
 
45
55
  ## API
46
56
 
47
- **globSync(pattern: string \| string[], options: GlobOptions): string[]**
57
+ **globSync(pattern: string \| string[], options?: GlobOptions): string[]**
48
58
  Synchronously returns an array of file paths.
49
59
 
50
- **glob(pattern: string \| string[], options: GlobOptions): Promise<string[]>**
60
+ **glob(pattern: string \| string[], options?: GlobOptions): Promise<string[]>**
51
61
  Asynchronously returns an array of file paths.
52
62
 
53
63
  ## License
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  export interface GlobOptions {
7
7
  exclude?: Array<string>
8
- cwd: string
8
+ cwd?: string
9
9
  }
10
- export declare function globSync(patterns: string | Array<string>, options: GlobOptions): Array<string>
11
- export declare function glob(patterns: string | Array<string>, options: GlobOptions): Promise<Array<string>>
10
+ export declare function globSync(patterns: string | Array<string>, options?: GlobOptions | undefined | null): Array<string>
11
+ export declare function glob(patterns: string | Array<string>, options?: GlobOptions | undefined | null): Promise<Array<string>>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rust-gear/glob",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Node.js bindings for Rust glob library",
5
5
  "keywords": [
6
6
  "rust-gear",
@@ -53,14 +53,14 @@
53
53
  "@napi-rs/cli": "^2.18.4"
54
54
  },
55
55
  "optionalDependencies": {
56
- "@rust-gear/glob-darwin-arm64": "0.2.0",
57
- "@rust-gear/glob-darwin-x64": "0.2.0",
58
- "@rust-gear/glob-linux-arm64-gnu": "0.2.0",
59
- "@rust-gear/glob-linux-arm64-musl": "0.2.0",
60
- "@rust-gear/glob-linux-x64-gnu": "0.2.0",
61
- "@rust-gear/glob-linux-x64-musl": "0.2.0",
62
- "@rust-gear/glob-win32-arm64-msvc": "0.2.0",
63
- "@rust-gear/glob-win32-ia32-msvc": "0.2.0",
64
- "@rust-gear/glob-win32-x64-msvc": "0.2.0"
56
+ "@rust-gear/glob-darwin-arm64": "0.2.2",
57
+ "@rust-gear/glob-darwin-x64": "0.2.2",
58
+ "@rust-gear/glob-linux-arm64-gnu": "0.2.2",
59
+ "@rust-gear/glob-linux-arm64-musl": "0.2.2",
60
+ "@rust-gear/glob-linux-x64-gnu": "0.2.2",
61
+ "@rust-gear/glob-linux-x64-musl": "0.2.2",
62
+ "@rust-gear/glob-win32-arm64-msvc": "0.2.2",
63
+ "@rust-gear/glob-win32-ia32-msvc": "0.2.2",
64
+ "@rust-gear/glob-win32-x64-msvc": "0.2.2"
65
65
  }
66
66
  }