Skip to content

Commit 05b4289

Browse files
committed
fix: fix broken way of using spawn
1 parent f57cf02 commit 05b4289

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async function cocoapodsVersion(root: string): Promise<string> {
181181
let podVersionOutput = '';
182182
try {
183183
// 1st: try to run CocoaPods via bundler
184-
podVersionOutput = await subProcess.execute('bundle exec pod', ['--version'], {cwd: root});
184+
podVersionOutput = await subProcess.execute('bundle', ['exec', 'pod', '--version'], {cwd: root});
185185
} catch {
186186
try {
187187
// 2nd: try to run CocoaPods directly

test/lib/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('inspect(rootDir, targetFile?, options?)', () => {
3636
});
3737

3838
expect(mockedExecute.mock.calls).toEqual([
39-
['bundle exec pod', ['--version'], { cwd: rootDir }],
39+
['bundle', ['exec', 'pod', '--version'], { cwd: rootDir }],
4040
]);
4141
});
4242

@@ -54,7 +54,7 @@ describe('inspect(rootDir, targetFile?, options?)', () => {
5454
});
5555

5656
expect(mockedExecute.mock.calls).toEqual([
57-
['bundle exec pod', ['--version'], { cwd: rootDir }],
57+
['bundle', ['exec', 'pod', '--version'], { cwd: rootDir }],
5858
['pod', ['--version'], { cwd: rootDir }],
5959
]);
6060
});
@@ -73,7 +73,7 @@ describe('inspect(rootDir, targetFile?, options?)', () => {
7373
});
7474

7575
expect(mockedExecute.mock.calls).toEqual([
76-
['bundle exec pod', ['--version'], { cwd: rootDir }],
76+
['bundle', ['exec', 'pod', '--version'], { cwd: rootDir }],
7777
['pod', ['--version'], { cwd: rootDir }],
7878
]);
7979
});

test/lib/sub-process.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,37 @@ import * as subProcess from '../../lib/sub-process';
33
describe('execute()', () => {
44
test('Resolves when the command succeeds', async () => {
55
await expect(
6-
subProcess.execute('echo "success" && echo "ignore" >&2 && true'),
6+
subProcess.execute('sh', [
7+
'-c',
8+
'echo "success" && echo "ignore" >&2 && true',
9+
]),
710
).resolves.toEqual('success\n');
811
});
912

1013
test('Resolves with stderr when the command succeeds and there is no stdout', async () => {
1114
await expect(
12-
subProcess.execute('echo "warn" >&2 && true'),
15+
subProcess.execute('sh', ['-c', 'echo "warn" >&2 && true']),
1316
).resolves.toMatch('warn\n');
1417
});
1518

1619
test('Rejects with stdout when the command fails', async () => {
1720
await expect(
18-
subProcess.execute('echo "error msg" && echo "ignore" >&2 && false'),
21+
subProcess.execute('sh', [
22+
'-c',
23+
'echo "error msg" && echo "ignore" >&2 && false',
24+
]),
1925
).rejects.toThrow('error msg\n');
2026
});
2127

2228
test('Rejects with stderr when the command fails and there is no stdout', async () => {
2329
await expect(
24-
subProcess.execute('echo "error msg" >&2 && false'),
30+
subProcess.execute('sh', ['-c', 'echo "error msg" >&2 && false']),
2531
).rejects.toThrow('error msg\n');
2632
});
2733

2834
test('Considers option.cwd', async () => {
2935
await expect(
30-
subProcess.execute('basename $PWD', [], { cwd: __dirname }),
36+
subProcess.execute('sh', ['-c', 'basename $PWD'], { cwd: __dirname }),
3137
).resolves.toEqual('lib\n');
3238
});
3339

0 commit comments

Comments
 (0)