Skip to content

Commit

Permalink
fix: fix findUp for Windows (#640)
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Chau <[email protected]>
  • Loading branch information
Mobyrr and Akryum authored Nov 25, 2023
1 parent dcb5024 commit ec40fec
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/histoire/src/node/util/find-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import path from 'pathe'
import fs from 'node:fs'

export function findUp (cwd: string = process.cwd(), fileNames: string[]): string {
const { root } = path.parse(cwd)
let { root } = path.parse(cwd)
let dir = cwd

// On Windows, it will for example return `C:`, we need to add the trailing `/`
if (root[1] === ':' && root[2] === undefined) {
root += '/'
}

while (dir !== root) {
for (const fileName of fileNames) {
const searchPath = path.join(dir, fileName)
Expand Down

0 comments on commit ec40fec

Please sign in to comment.