File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 65
65
"@types/fs-extra" : " ^9.0.5" ,
66
66
"aegir" : " ^30.3.0" ,
67
67
"delay" : " ^5.0.0" ,
68
+ "ipfs-unixfs" : " ^4.0.1" ,
68
69
"it-all" : " ^1.0.4" ,
69
70
"it-drain" : " ^1.0.3" ,
70
71
"it-last" : " ^1.0.4" ,
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ const errCode = require('err-code')
17
17
* @param {boolean } [options.preserveMode] - preserve mode
18
18
* @param {boolean } [options.preserveMtime] - preserve mtime
19
19
* @param {number } [options.mode] - mode to use - if preserveMode is true this will be ignored
20
- * @param {Date } [options.mtime] - mtime to use - if preserveMtime 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
21
* @yields {Object} File objects in the form `{ path: String, content: AsyncIterator<Buffer> }`
22
22
*/
23
23
module . exports = async function * globSource ( paths , options ) {
Original file line number Diff line number Diff line change @@ -233,4 +233,40 @@ describe('glob-source', () => {
233
233
expect ( result ) . to . have . nested . property ( '[5].path' , '/dir/nested-dir/other.txt' )
234
234
expect ( result ) . to . have . deep . nested . property ( '[5].mtime' , new Date ( 5 ) )
235
235
} )
236
+
237
+ it ( 'overrides mtime for file with secs/nsecs' , async function ( ) {
238
+ if ( ! isNode ) {
239
+ return this . skip ( )
240
+ }
241
+
242
+ const result = await all ( globSource ( fixture ( '/dir/file-1.txt' ) , {
243
+ mtime : { secs : 5 , nsecs : 0 }
244
+ } ) )
245
+
246
+ expect ( result ) . to . have . deep . nested . property ( '[0].mtime' , { secs : 5 , nsecs : 0 } )
247
+ } )
248
+
249
+ it ( 'overrides mtime for file with hrtime' , async function ( ) {
250
+ if ( ! isNode ) {
251
+ return this . skip ( )
252
+ }
253
+
254
+ const result = await all ( globSource ( fixture ( '/dir/file-1.txt' ) , {
255
+ mtime : [ 5 , 0 ]
256
+ } ) )
257
+
258
+ expect ( result ) . to . have . deep . nested . property ( '[0].mtime' , [ 5 , 0 ] )
259
+ } )
260
+
261
+ it ( 'overrides mtime for file with UnixFS timespec' , async function ( ) {
262
+ if ( ! isNode ) {
263
+ return this . skip ( )
264
+ }
265
+
266
+ const result = await all ( globSource ( fixture ( '/dir/file-1.txt' ) , {
267
+ mtime : { Seconds : 5 , FractionalNanoseconds : 0 }
268
+ } ) )
269
+
270
+ expect ( result ) . to . have . deep . nested . property ( '[0].mtime' , { Seconds : 5 , FractionalNanoseconds : 0 } )
271
+ } )
236
272
} )
You can’t perform that action at this time.
0 commit comments