Skip to content

Commit 5d29f4d

Browse files
author
cod1k
committed
Remove redundant command and enhance file copy with ignore logic
Removed the `clean:test-applications` command from e2e test setup as it is unnecessary. Improved the `copyToTemp` function by integrating `.gitignore` and `node_modules` filtering to exclude unwanted files during the copy process. This ensures a cleaner and more efficient temporary workspace.
1 parent 40266ff commit 5d29f4d

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

dev-packages/e2e-tests/lib/copyToTemp.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
/* eslint-disable no-console */
2-
import { readFileSync, writeFileSync } from 'fs';
2+
import { existsSync, readFileSync, writeFileSync } from 'fs';
33
import { cp } from 'fs/promises';
4-
import { join } from 'path';
4+
import ignore from 'ignore';
5+
import { dirname, join, relative } from 'path';
56

67
export async function copyToTemp(originalPath: string, tmpDirPath: string): Promise<void> {
78
// copy files to tmp dir
8-
await cp(originalPath, tmpDirPath, { recursive: true });
9+
const ig = ignore();
10+
const ignoreFileDirs = [
11+
originalPath,
12+
dirname(__dirname)
13+
]
14+
ig.add(['.gitignore', 'node_modules', 'dist', 'build']);
15+
for(const dir of ignoreFileDirs) {
16+
const ignore_file = join(dir, '.gitignore');
17+
if (existsSync(ignore_file)) {
18+
ig.add(readFileSync(ignore_file, 'utf8'));
19+
}
20+
}
21+
22+
await cp(originalPath, tmpDirPath, {
23+
recursive: true,
24+
filter: src => {
25+
const relPath = relative(originalPath, src);
26+
if (!relPath) return true;
27+
return !ig.ignores(relPath);
28+
},
29+
});
930

1031
fixPackageJson(tmpDirPath);
1132
}

dev-packages/e2e-tests/run.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ async function run(): Promise<void> {
6868
registrySetup();
6969
}
7070

71-
await asyncExec('pnpm clean:test-applications', { env, cwd: __dirname });
7271
await asyncExec('pnpm cache delete "@sentry/*"', { env, cwd: __dirname });
7372

7473
const testAppPaths = appName ? [appName.trim()] : globSync('*', { cwd: `${__dirname}/test-applications/` });

0 commit comments

Comments
 (0)