From 909cc0ccf969f9a57a19a65720477fd2c8fae9e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 10:47:09 +0000 Subject: [PATCH 1/3] deps: bump it-glob from 2.0.7 to 3.0.1 Bumps [it-glob](https://github.com/achingbrain/it) from 2.0.7 to 3.0.1. - [Release notes](https://github.com/achingbrain/it/releases) - [Commits](https://github.com/achingbrain/it/compare/it-glob-2.0.7...it-glob-3.0.1) --- updated-dependencies: - dependency-name: it-glob dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc5c89960..ea35b0145 100644 --- a/package.json +++ b/package.json @@ -167,7 +167,7 @@ "iso-url": "^1.2.1", "it-all": "^3.0.4", "it-first": "^3.0.4", - "it-glob": "^2.0.6", + "it-glob": "^3.0.1", "it-last": "^3.0.4", "it-map": "^3.0.5", "it-peekable": "^3.0.3", From df63790839ba280240fd697f1de44dcbf9a12afd Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 12 Sep 2024 11:30:57 +0100 Subject: [PATCH 2/3] chore: fix tests --- src/lib/glob-source.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/glob-source.ts b/src/lib/glob-source.ts index 76329ed25..dc2981182 100644 --- a/src/lib/glob-source.ts +++ b/src/lib/glob-source.ts @@ -4,6 +4,7 @@ import Path from 'node:path' import { CodeError } from '@libp2p/interface' import glob from 'it-glob' import type { MtimeLike } from 'ipfs-unixfs' +import type { Options as GlobOptions } from 'it-glob' export interface GlobSourceOptions { /** @@ -58,15 +59,19 @@ export async function * globSource (cwd: string, pattern: string, options?: Glob cwd = Path.resolve(process.cwd(), cwd) } - const globOptions = Object.assign({}, { - nodir: false, - realpath: false, + const globOptions: GlobOptions = Object.assign({}, { + onlyFiles: false, absolute: true, dot: Boolean(options.hidden), - follow: options.followSymlinks ?? true - }) + followSymbolicLinks: options.followSymlinks ?? true + } satisfies GlobOptions) for await (const p of glob(cwd, pattern, globOptions)) { + // Workaround for https://github.com/micromatch/micromatch/issues/251 + if (Path.basename(p).startsWith('.') && options.hidden !== true) { + continue + } + const stat = await fsp.stat(p) let mode = options.mode From 7709c42e5ee6b68c68787b378b3273fff30bdae9 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 12 Sep 2024 11:50:40 +0100 Subject: [PATCH 3/3] chore: fix windows --- src/lib/glob-source.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/glob-source.ts b/src/lib/glob-source.ts index dc2981182..a4818c6c6 100644 --- a/src/lib/glob-source.ts +++ b/src/lib/glob-source.ts @@ -1,5 +1,6 @@ import fs from 'node:fs' import fsp from 'node:fs/promises' +import os from 'node:os' import Path from 'node:path' import { CodeError } from '@libp2p/interface' import glob from 'it-glob' @@ -59,6 +60,10 @@ export async function * globSource (cwd: string, pattern: string, options?: Glob cwd = Path.resolve(process.cwd(), cwd) } + if (os.platform() === 'win32') { + cwd = toPosix(cwd) + } + const globOptions: GlobOptions = Object.assign({}, { onlyFiles: false, absolute: true, @@ -87,7 +92,7 @@ export async function * globSource (cwd: string, pattern: string, options?: Glob } yield { - path: toPosix(p.replace(cwd, '')), + path: p.replace(cwd, ''), content: stat.isFile() ? fs.createReadStream(p) : undefined, mode, mtime