Skip to content

Commit 7c012ed

Browse files
feat: cwd
1 parent 85b40fc commit 7c012ed

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/services/deps.services.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@ export const dependencies = async ({where}: PopulateInput) => {
1717
try {
1818
const pm = whichPMRuns();
1919

20-
const args = [
21-
'install',
22-
...(nonNullish(where) && where !== '' ? ['--prefix', where ?? ''] : [])
23-
];
24-
25-
console.log(pm, args);
26-
2720
await spawn({
2821
command: pm,
29-
args,
30-
silentOut: true
22+
args: ['install'],
23+
silentOut: true,
24+
...(nonNullish(where) && where !== '' && {cwd: where})
3125
});
3226
} finally {
3327
spinner.stop();

src/utils/cmd.utils.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {nonNullish} from '@junobuild/utils';
12
import {
23
spawn as spawnCommand,
34
type ChildProcess,
@@ -11,16 +12,21 @@ export const spawn = async ({
1112
args,
1213
stdout,
1314
silentOut = false,
14-
silentErrors = false
15+
silentErrors = false,
16+
cwd
1517
}: {
1618
command: string;
19+
cwd?: string;
1720
args?: readonly string[];
1821
stdout?: (output: string) => void;
1922
silentOut?: boolean;
2023
silentErrors?: boolean;
2124
}): Promise<number | null> => {
2225
return await new Promise<number | null>((resolve, reject) => {
23-
const process: ChildProcessWithoutNullStreams = spawnCommand(command, args, { shell: true });
26+
const process: ChildProcessWithoutNullStreams = spawnCommand(command, args, {
27+
shell: true,
28+
...(nonNullish(cwd) && {cwd})
29+
});
2430

2531
process.stdout.on('data', (data) => {
2632
if (stdout !== null && stdout !== undefined) {

0 commit comments

Comments
 (0)