Skip to content

Commit 1dc939f

Browse files
authored
fix: fix unixfs import (#222)
Update import for `MtimeLike` type otherwise incorrect paths are generated during compilation.
1 parent b0c7d35 commit 1dc939f

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

src/files/glob-source.js

+8-13
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@ const glob = require('it-glob')
66
const Path = require('path')
77
const errCode = require('err-code')
88

9+
/**
10+
* @typedef {import('ipfs-unixfs').MtimeLike} MtimeLike
11+
* @typedef {import('../types').GlobSourceOptions} GlobSourceOptions
12+
* @typedef {import('../types').GlobSourceResult} GlobSourceResult
13+
*/
14+
915
/**
1016
* Create an async iterator that yields paths that match requested glob pattern
1117
*
1218
* @param {string} cwd - The directory to start matching the pattern in
1319
* @param {string} pattern - Glob pattern to match
14-
* @param {Object} [options] - Optional options
15-
* @param {boolean} [options.hidden] - Include .dot files in matched paths
16-
* @param {boolean} [options.followSymlinks] - follow symlinks
17-
* @param {boolean} [options.preserveMode] - preserve mode
18-
* @param {boolean} [options.preserveMtime] - preserve mtime
19-
* @param {number} [options.mode] - mode to use - if preserveMode is true this will be ignored
20-
* @param {import('ipfs-unixfs').MtimeLike} [options.mtime] - mtime to use - if preserveMtime is true this will be ignored
21-
* @returns {AsyncGenerator<{
22-
* path: string;
23-
* content: AsyncIterable<Buffer> | undefined;
24-
* mode: number | undefined;
25-
* mtime: import("ipfs-unixfs/types/src/types").MtimeLike | undefined;
26-
* }, void, unknown>} File objects that match glob
20+
* @param {GlobSourceOptions} [options] - Optional options
21+
* @returns {AsyncGenerator<GlobSourceResult, void, unknown>} File objects that match glob
2722
*/
2823
module.exports = async function * globSource (cwd, pattern, options) {
2924
options = options || {}

src/types.d.ts

+40
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Readable as NodeReadableStream } from 'stream'
2+
import type { MtimeLike } from 'ipfs-unixfs'
23

34
interface ProgressStatus {
45
total: number
@@ -64,3 +65,42 @@ export interface ExtendedResponse extends Response {
6465

6566
ndjson: () => AsyncGenerator<any, void, undefined>
6667
}
68+
69+
export interface GlobSourceOptions {
70+
/**
71+
* Include .dot files in matched paths
72+
*/
73+
hidden?: boolean
74+
75+
/**
76+
* follow symlinks
77+
*/
78+
followSymlinks?: boolean
79+
80+
/**
81+
* Preserve mode
82+
*/
83+
preserveMode?: boolean
84+
85+
/**
86+
* Preserve mtime
87+
*/
88+
preserveMtime?: boolean
89+
90+
/**
91+
* mode to use - if preserveMode is true this will be ignored
92+
*/
93+
mode?: number
94+
95+
/**
96+
* mtime to use - if preserveMtime is true this will be ignored
97+
*/
98+
mtime?: MtimeLike
99+
}
100+
101+
export interface GlobSourceResult {
102+
path: string
103+
content: AsyncIterable<Uint8Array> | undefined
104+
mode: number | undefined
105+
mtime: MtimeLike | undefined
106+
}

0 commit comments

Comments
 (0)