Skip to content

Commit d5597a4

Browse files
author
Moritz Benzenhöfer
committed
Support sub module discovery
1 parent 76eeed9 commit d5597a4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/patchFs.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import * as fs from "fs-extra"
2-
import { join } from "./path"
2+
import { join, relative } from "./path"
33

44
function _getPatchFiles(
5-
rootPatchesDir: string,
5+
currentPatchesDir: string,
66
scopedDir: string = "",
77
acc: string[] = [],
8+
rootPatchesDir: string,
89
) {
9-
fs.readdirSync(join(rootPatchesDir, scopedDir)).forEach(filename => {
10+
fs.readdirSync(join(currentPatchesDir, scopedDir)).forEach(filename => {
1011
if (filename.endsWith(".patch")) {
11-
acc.push(join(scopedDir, filename))
12-
} else if (
13-
filename.startsWith("@") &&
14-
fs.statSync(join(rootPatchesDir, filename)).isDirectory()
15-
) {
16-
_getPatchFiles(rootPatchesDir, filename, acc)
12+
acc.push(
13+
relative(rootPatchesDir, join(currentPatchesDir, scopedDir, filename)),
14+
)
15+
} else if (fs.statSync(join(currentPatchesDir, filename)).isDirectory()) {
16+
_getPatchFiles(join(currentPatchesDir, filename), "", acc, rootPatchesDir)
1717
}
1818
})
1919
return acc
2020
}
2121

2222
export const getPatchFiles = (patchesDir: string) => {
23-
return _getPatchFiles(patchesDir).filter(filename =>
24-
filename.match(/^.+(:|\+).+\.patch$/),
23+
return _getPatchFiles(patchesDir, undefined, [], patchesDir).filter(
24+
filename => filename.match(/^.+(:|\+).+\.patch$/),
2525
)
2626
}

0 commit comments

Comments
 (0)