|
2 | 2 |
|
3 | 3 | import fg from "fast-glob";
|
4 | 4 | import fsExtra from "fs-extra";
|
5 |
| -import { existsSync, readFileSync, writeFileSync } from "fs"; |
| 5 | +import { existsSync, readFileSync, writeFileSync, cpSync, lstatSync, realpathSync } from "fs"; |
6 | 6 | import { dirname, join, parse } from "path";
|
7 |
| -import copy from "recursive-copy"; |
8 | 7 | import { promisify } from "util";
|
9 | 8 | import resolve from "resolve";
|
10 | 9 | import _ from "lodash";
|
@@ -172,15 +171,36 @@ export async function copyJsModule(moduleSourcePath, to) {
|
172 | 171 | if (existsSync(to)) {
|
173 | 172 | return;
|
174 | 173 | }
|
175 |
| - return promisify(copy)(moduleSourcePath, to, { |
176 |
| - filter: [ |
177 |
| - "**/*.*", |
178 |
| - LICENSE_GLOB, |
179 |
| - "!**/{android,ios,windows,mac,jest,github,gradle,__*__,docs,jest,example*}/**/*", |
180 |
| - "!**/*.{config,setup}.*", |
181 |
| - "!**/*.{podspec,flow}" |
182 |
| - ], |
183 |
| - overwrite: true |
| 174 | + |
| 175 | + // Check if the source is a symlink and resolve it to the actual path |
| 176 | + let actualSourcePath = moduleSourcePath; |
| 177 | + if (lstatSync(moduleSourcePath).isSymbolicLink()) { |
| 178 | + actualSourcePath = realpathSync(moduleSourcePath); |
| 179 | + } |
| 180 | + |
| 181 | + cpSync(actualSourcePath, to, { |
| 182 | + recursive: true, |
| 183 | + dereference: true, // Follow symlinks and copy the actual files |
| 184 | + filter: (src, dest) => { |
| 185 | + const relativePath = src.replace(actualSourcePath, "").replace(/^[\\/]/, ""); |
| 186 | + |
| 187 | + // Skip certain directories |
| 188 | + if (relativePath.match(/[\\/](android|ios|windows|mac|jest|github|gradle|__.*__|docs|example.*)[\\/]/)) { |
| 189 | + return false; |
| 190 | + } |
| 191 | + |
| 192 | + // Skip certain file types |
| 193 | + if (relativePath.match(/\.(config|setup)\.|\.podspec$|\.flow$/)) { |
| 194 | + return false; |
| 195 | + } |
| 196 | + |
| 197 | + // Include LICENSE files |
| 198 | + if (relativePath.match(/license/i)) { |
| 199 | + return true; |
| 200 | + } |
| 201 | + |
| 202 | + return true; |
| 203 | + } |
184 | 204 | });
|
185 | 205 | }
|
186 | 206 |
|
|
0 commit comments