Skip to content

Commit de3a4e5

Browse files
fix: handle symlinks in dev mode linking (#390)
1 parent 2445838 commit de3a4e5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/utils/link.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Options } from "ncp";
2-
import { existsSync, lstatSync, readdirSync } from "fs";
2+
import { existsSync, lstatSync, readdirSync, readlinkSync } from "fs";
33
import { promises } from "fs";
44
import path from "path";
55

6-
const { mkdir, link } = promises;
6+
const { mkdir, link, symlink } = promises;
77

88
const passesFilter = (source: string, options?: Options) => {
99
const isDSStore = /\.DS_Store$/.test(source);
@@ -28,7 +28,14 @@ const linkRecursive = async (source: string, destination: string, options?: Opti
2828
return;
2929
}
3030

31-
if (lstatSync(source).isDirectory()) {
31+
const stat = lstatSync(source);
32+
33+
if (stat.isSymbolicLink()) {
34+
const linkTarget = readlinkSync(source);
35+
return symlink(linkTarget, destination);
36+
}
37+
38+
if (stat.isDirectory()) {
3239
const subPaths = readdirSync(source);
3340
await Promise.all(
3441
subPaths.map(async subPath => {

0 commit comments

Comments
 (0)