@rust-gear/glob 0.2.0 → 0.2.1
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.
- package/README.md +18 -8
- package/index.d.ts +3 -3
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -13,20 +13,20 @@ 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"
|
|
16
|
+
const files = globSync("src/**/*.rs");
|
|
17
17
|
console.log(files);
|
|
18
18
|
|
|
19
|
-
const filesAsync = await glob("src/**/*.rs"
|
|
19
|
+
const filesAsync = await glob("src/**/*.rs");
|
|
20
20
|
console.log(filesAsync);
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Options
|
|
24
24
|
|
|
25
|
-
You
|
|
26
|
-
The `cwd` option is **required**.
|
|
25
|
+
You can pass an options object as the second argument to `globSync/glob`.
|
|
27
26
|
|
|
28
|
-
> **
|
|
29
|
-
> If
|
|
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
31
|
| Option | Type | Description |
|
|
32
32
|
| :------ | :------- | :----------------------------------------------------- |
|
|
@@ -36,18 +36,28 @@ The `cwd` option is **required**.
|
|
|
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
|
|
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
|
|
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
|
|
8
|
+
cwd?: string
|
|
9
9
|
}
|
|
10
|
-
export declare function globSync(patterns: string | Array<string>, options
|
|
11
|
-
export declare function glob(patterns: string | Array<string>, options
|
|
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.
|
|
3
|
+
"version": "0.2.1",
|
|
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.
|
|
57
|
-
"@rust-gear/glob-darwin-x64": "0.2.
|
|
58
|
-
"@rust-gear/glob-linux-arm64-gnu": "0.2.
|
|
59
|
-
"@rust-gear/glob-linux-arm64-musl": "0.2.
|
|
60
|
-
"@rust-gear/glob-linux-x64-gnu": "0.2.
|
|
61
|
-
"@rust-gear/glob-linux-x64-musl": "0.2.
|
|
62
|
-
"@rust-gear/glob-win32-arm64-msvc": "0.2.
|
|
63
|
-
"@rust-gear/glob-win32-ia32-msvc": "0.2.
|
|
64
|
-
"@rust-gear/glob-win32-x64-msvc": "0.2.
|
|
56
|
+
"@rust-gear/glob-darwin-arm64": "0.2.1",
|
|
57
|
+
"@rust-gear/glob-darwin-x64": "0.2.1",
|
|
58
|
+
"@rust-gear/glob-linux-arm64-gnu": "0.2.1",
|
|
59
|
+
"@rust-gear/glob-linux-arm64-musl": "0.2.1",
|
|
60
|
+
"@rust-gear/glob-linux-x64-gnu": "0.2.1",
|
|
61
|
+
"@rust-gear/glob-linux-x64-musl": "0.2.1",
|
|
62
|
+
"@rust-gear/glob-win32-arm64-msvc": "0.2.1",
|
|
63
|
+
"@rust-gear/glob-win32-ia32-msvc": "0.2.1",
|
|
64
|
+
"@rust-gear/glob-win32-x64-msvc": "0.2.1"
|
|
65
65
|
}
|
|
66
66
|
}
|