Skip to content

Commit

Permalink
[eas-cli] Fix symlink support (#2874)
Browse files Browse the repository at this point in the history
<!-- 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.
  • Loading branch information
sjchmiela authored Feb 5, 2025
1 parent a2929ad commit f5480b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This is the log of notable changes to EAS CLI and related packages.
### 🐛 Bug fixes

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

### 🧹 Chores

Expand Down
14 changes: 9 additions & 5 deletions packages/eas-cli/src/vcs/local.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fg from 'fast-glob';
import fs from 'fs-extra';
import fs from 'fs/promises';
import fsExtra from 'fs-extra';
import createIgnore, { Ignore as SingleFileIgnore } from 'ignore';
import path from 'path';

Expand Down Expand Up @@ -42,10 +43,10 @@ export class Ignore {

public async initIgnoreAsync(): Promise<void> {
const easIgnorePath = path.join(this.rootDir, EASIGNORE_FILENAME);
if (await fs.pathExists(easIgnorePath)) {
if (await fsExtra.pathExists(easIgnorePath)) {
this.ignoreMapping = [
['', createIgnore().add(DEFAULT_IGNORE)],
['', createIgnore().add(await fs.readFile(easIgnorePath, 'utf-8'))],
['', createIgnore().add(await fsExtra.readFile(easIgnorePath, 'utf-8'))],
];
return;
}
Expand All @@ -63,7 +64,7 @@ export class Ignore {
ignoreFilePaths.map(async filePath => {
return [
filePath.slice(0, filePath.length - GITIGNORE_FILENAME.length),
createIgnore().add(await fs.readFile(path.join(this.rootDir, filePath), 'utf-8')),
createIgnore().add(await fsExtra.readFile(path.join(this.rootDir, filePath), 'utf-8')),
] as const;
})
);
Expand All @@ -82,7 +83,10 @@ export class Ignore {

export async function makeShallowCopyAsync(src: string, dst: string): Promise<void> {
const ignore = await Ignore.createAsync(src);
await fs.copy(src, dst, {
await fs.cp(src, dst, {
recursive: true,
// Preserve symlinks without re-resolving them to their original targets
verbatimSymlinks: true,
filter: (srcFilePath: string) => {
if (srcFilePath === src) {
return true;
Expand Down

0 comments on commit f5480b4

Please sign in to comment.