Skip to content

Commit 4160a8e

Browse files
committed
fix: use test -f instead of cat for file existence checks in snap tests
Alpine's cat outputs "can't open" while GNU cat outputs "No such file or directory". Use test ! -f which is portable and produces no output.
1 parent 7986818 commit 4160a8e

36 files changed

Lines changed: 49 additions & 82 deletions

File tree

packages/cli/snap-tests-global/command-pack-exe/steps.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99
"env": {
1010
"VITE_DISABLE_AUTO_INSTALL": "1"
1111
},
12-
"commands": [
13-
"vp pack src/index.ts --exe 2>&1",
14-
"ls dist",
15-
"ls build",
16-
"./build/index"
17-
],
18-
"after": [
19-
"rm -rf dist",
20-
"rm -rf build"
21-
]
12+
"commands": ["vp pack src/index.ts --exe 2>&1", "ls dist", "ls build", "./build/index"],
13+
"after": ["rm -rf dist", "rm -rf build"]
2214
}

packages/cli/snap-tests-global/migration-already-vite-plus/steps.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"commands": [
3-
"vp migrate --no-interactive # should detect existing vite-plus and exit"
4-
],
2+
"commands": ["vp migrate --no-interactive # should detect existing vite-plus and exit"],
53
"ignoredPlatforms": [
64
{
75
"os": "linux",

packages/cli/snap-tests-global/migration-auto-create-vite-config/snap.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ export default defineConfig({
3030
},
3131
});
3232

33-
> cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed
34-
cat: .oxlintrc.json: No such file or directory
33+
> test ! -f .oxlintrc.json # check .oxlintrc.json is removed
3534

36-
> cat .oxfmtrc.json && exit 1 || true # check .oxfmtrc.json is removed
37-
cat: .oxfmtrc.json: No such file or directory
35+
> test ! -f .oxfmtrc.json # check .oxfmtrc.json is removed
3836

3937
> cat package.json # check package.json
4038
{

packages/cli/snap-tests-global/migration-auto-create-vite-config/steps.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"commands": [
33
"vp migrate --no-interactive 2>&1 # migration should auto create vite.config.ts and remove oxlintrc and oxfmtrc",
44
"cat vite.config.ts # check vite.config.ts",
5-
"cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed",
6-
"cat .oxfmtrc.json && exit 1 || true # check .oxfmtrc.json is removed",
5+
"test ! -f .oxlintrc.json # check .oxlintrc.json is removed",
6+
"test ! -f .oxfmtrc.json # check .oxfmtrc.json is removed",
77
"cat package.json # check package.json"
88
]
99
}

packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ export default defineConfig({
2323
},
2424
});
2525

26-
> cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed
27-
cat: .oxlintrc.json: No such file or directory
26+
> test ! -f .oxlintrc.json # check .oxlintrc.json is removed
2827

2928
> cat package.json # check package.json
3029
{

packages/cli/snap-tests-global/migration-baseurl-tsconfig/steps.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"commands": [
33
"vp migrate --no-interactive # migration should skip typeAware/typeCheck when tsconfig has baseUrl",
44
"cat vite.config.ts # check vite.config.ts — should NOT have typeAware or typeCheck",
5-
"cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed",
5+
"test ! -f .oxlintrc.json # check .oxlintrc.json is removed",
66
"cat package.json # check package.json"
77
]
88
}

packages/cli/snap-tests-global/migration-eslint-monorepo/snap.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,4 @@ VITE+ - The Unified Toolchain for the Web
5050
"devDependencies": {}
5151
}
5252

53-
> cat eslint.config.mjs && exit 1 || true # check root eslint config is removed
54-
cat: eslint.config.mjs: No such file or directory
53+
> test ! -f eslint.config.mjs # check root eslint config is removed

packages/cli/snap-tests-global/migration-eslint-monorepo/steps.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"cat package.json # check root eslint removed and scripts rewritten",
55
"cat packages/app/package.json # check app eslint removed and scripts rewritten",
66
"cat packages/utils/package.json # check utils eslint removed and scripts rewritten",
7-
"cat eslint.config.mjs && exit 1 || true # check root eslint config is removed"
7+
"test ! -f eslint.config.mjs # check root eslint config is removed"
88
]
99
}

packages/cli/snap-tests-global/migration-eslint-npx-wrapper/snap.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ VITE+ - The Unified Toolchain for the Web
3131
}
3232
}
3333

34-
> cat eslint.config.mjs && exit 1 || true # check eslint config is removed
35-
cat: eslint.config.mjs: No such file or directory
34+
> test ! -f eslint.config.mjs # check eslint config is removed

packages/cli/snap-tests-global/migration-eslint-npx-wrapper/steps.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"commands": [
33
"vp migrate --no-interactive # migration should rewrite bare eslint but leave npx wrappers unchanged",
44
"cat package.json # check eslint removed, bare eslint rewritten, npx/pnpm exec/bunx wrappers unchanged",
5-
"cat eslint.config.mjs && exit 1 || true # check eslint config is removed"
5+
"test ! -f eslint.config.mjs # check eslint config is removed"
66
]
77
}

0 commit comments

Comments
 (0)