File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 11import type { Dependency } from './types'
2- import { pkexec } from '../system/exec'
2+ import { pkexec , execWithSudo } from '../system/exec'
33import { system } from 'gluegun'
44import type { Result } from '../../types'
55import { failure , wrapAsync } from './errors'
@@ -44,11 +44,19 @@ export async function installPackages(packages: Dependency[]): Promise<Result<vo
4444 const packageManager = system . which ( 'apt' )
4545
4646 if ( packageManager !== null && packageManager !== undefined ) {
47- const result = await pkexec (
48- `${ packageManager } install --yes ${ packages . map ( ( p ) => p . packageName ) . join ( ' ' ) } ` ,
49- { stdout : process . stdout } ,
50- )
51- return result
47+ if ( typeof process . env . CI !== 'undefined' && process . env . CI !== 'false' ) {
48+ const result = await execWithSudo (
49+ `${ packageManager } install --yes ${ packages . map ( ( p ) => p . packageName ) . join ( ' ' ) } ` ,
50+ { stdout : process . stdout } ,
51+ )
52+ return result
53+ } else {
54+ const result = await pkexec (
55+ `${ packageManager } install --yes ${ packages . map ( ( p ) => p . packageName ) . join ( ' ' ) } ` ,
56+ { stdout : process . stdout } ,
57+ )
58+ return result
59+ }
5260 } else {
5361 return failure (
5462 `xs-dev attempted to install dependencies, but does not yet support your package manager. ` +
You can’t perform that action at this time.
0 commit comments