Skip to content

Commit f5480b4

Browse files
authored
[eas-cli] Fix symlink support (#2874)
<!-- If this PR requires a changelog entry, add it by commenting the PR with the command `/changelog-entry [breaking-change|new-feature|bug-fix|chore] [message]`. --> <!-- You can skip the changelog check by labeling the PR with "no changelog". --> # Why `fs-extra` fails to copy symbolic links as one would expect. jprichardson/node-fs-extra#708 # How We could: - copy and dereference symbolic links — make it so that the clone of the original directory has two copies of the files -- original and linked - copy symbolic links without re-resolving, assuming any links will be relative and should work when unpacked on a different machine. I think we can count on the latter. # Test Plan Created a link in my test repository ``` drwxr-xr-x 7 sjchmiela staff 224B Jan 28 16:14 assets lrwxr-xr-x 1 sjchmiela staff 6B Feb 4 22:12 assets-linked -> assets ``` ran ``` easd build:inspect -p android -s archive -o ~/testtest --force ``` confirmed I see ``` drwxr-xr-x 7 sjchmiela staff 224B Feb 4 22:20 assets lrwxr-xr-x 1 sjchmiela staff 6B Feb 4 22:20 assets-linked -> assets ``` in the result directory.
1 parent a2929ad commit f5480b4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This is the log of notable changes to EAS CLI and related packages.
1111
### 🐛 Bug fixes
1212

1313
- Fixed `GitClient` not respecting `.easignore` file. ([#2873](https://github.com/expo/eas-cli/pull/2873) by [@sjchmiela](https://github.com/sjchmiela))
14+
- Fix symlink support in `makeShallowCopyAsync`. ([#2874](https://github.com/expo/eas-cli/pull/2874) by [@sjchmiela](https://github.com/sjchmiela))
1415

1516
### 🧹 Chores
1617

packages/eas-cli/src/vcs/local.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fg from 'fast-glob';
2-
import fs from 'fs-extra';
2+
import fs from 'fs/promises';
3+
import fsExtra from 'fs-extra';
34
import createIgnore, { Ignore as SingleFileIgnore } from 'ignore';
45
import path from 'path';
56

@@ -42,10 +43,10 @@ export class Ignore {
4243

4344
public async initIgnoreAsync(): Promise<void> {
4445
const easIgnorePath = path.join(this.rootDir, EASIGNORE_FILENAME);
45-
if (await fs.pathExists(easIgnorePath)) {
46+
if (await fsExtra.pathExists(easIgnorePath)) {
4647
this.ignoreMapping = [
4748
['', createIgnore().add(DEFAULT_IGNORE)],
48-
['', createIgnore().add(await fs.readFile(easIgnorePath, 'utf-8'))],
49+
['', createIgnore().add(await fsExtra.readFile(easIgnorePath, 'utf-8'))],
4950
];
5051
return;
5152
}
@@ -63,7 +64,7 @@ export class Ignore {
6364
ignoreFilePaths.map(async filePath => {
6465
return [
6566
filePath.slice(0, filePath.length - GITIGNORE_FILENAME.length),
66-
createIgnore().add(await fs.readFile(path.join(this.rootDir, filePath), 'utf-8')),
67+
createIgnore().add(await fsExtra.readFile(path.join(this.rootDir, filePath), 'utf-8')),
6768
] as const;
6869
})
6970
);
@@ -82,7 +83,10 @@ export class Ignore {
8283

8384
export async function makeShallowCopyAsync(src: string, dst: string): Promise<void> {
8485
const ignore = await Ignore.createAsync(src);
85-
await fs.copy(src, dst, {
86+
await fs.cp(src, dst, {
87+
recursive: true,
88+
// Preserve symlinks without re-resolving them to their original targets
89+
verbatimSymlinks: true,
8690
filter: (srcFilePath: string) => {
8791
if (srcFilePath === src) {
8892
return true;

0 commit comments

Comments
 (0)