Skip to content

Commit 0df922c

Browse files
chrfalchclaude
andcommitted
CI: fix remaining Flow error in spm-ios-e2e.js execFileSync env
execFileSync's `env` option is invariantly typed {[string]: string | number | void}, so neither a plain process.env spread ({[string]: string | void}) nor a string-only object satisfies it. Build the env object into a correctly-typed indexer instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 18322da commit 0df922c

1 file changed

Lines changed: 12 additions & 21 deletions

File tree

scripts/e2e/spm-ios-e2e.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,36 +109,27 @@ function step(msg /*: string */) {
109109
console.log(`\n\x1b[35m==> ${msg}\x1b[0m`);
110110
}
111111

112-
// process.env is typed to allow numbers, but execFileSync's `env` option wants
113-
// string values only — copy across just the string entries.
114-
function stringEnv() /*: {[string]: string} */ {
115-
const out /*: {[string]: string} */ = {};
116-
for (const key of Object.keys(process.env)) {
117-
const value = process.env[key];
118-
if (typeof value === 'string') {
119-
out[key] = value;
120-
}
121-
}
122-
return out;
123-
}
124-
125112
function run(
126113
cmd /*: string */,
127114
args /*: Array<string> */,
128115
cwd /*: string */,
129116
env /*:: ?: {[string]: string} */,
130117
) /*: void */ {
131118
console.log(`$ (cd ${cwd} && ${cmd} ${args.join(' ')})`);
132-
// With no override, omit `env` so execFileSync inherits process.env as-is.
119+
// execFileSync's `env` option is invariantly typed as
120+
// {[string]: string | number | void}. process.env is {[string]: string | void}
121+
// and our overrides are strings, so a plain spread's narrower type is rejected;
122+
// build the object into a correctly-typed indexer instead.
123+
const childEnv /*: {[string]: string | number | void} */ = {};
124+
for (const key of Object.keys(process.env)) {
125+
childEnv[key] = process.env[key];
126+
}
133127
if (env != null) {
134-
execFileSync(cmd, args, {
135-
cwd,
136-
stdio: 'inherit',
137-
env: {...stringEnv(), ...env},
138-
});
139-
} else {
140-
execFileSync(cmd, args, {cwd, stdio: 'inherit'});
128+
for (const key of Object.keys(env)) {
129+
childEnv[key] = env[key];
130+
}
141131
}
132+
execFileSync(cmd, args, {cwd, stdio: 'inherit', env: childEnv});
142133
}
143134

144135
function resolveInRepoApp(app /*: 'rntester' | 'helloworld' */) /*: AppMeta */ {

0 commit comments

Comments
 (0)