File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,9 +107,10 @@ async function install(args: string[]) {
107107
108108 const self = fromFileUrl ( import . meta. url ) ;
109109 const pkgx_dir = Deno . env . get ( "PKGX_DIR" ) || `${ Deno . env . get ( "HOME" ) } /.pkgx` ;
110+ const needs_sudo = Deno . uid ( ) != 0 ;
110111
111- status = await new Deno . Command ( "/usr/bin/sudo" , {
112- args : [
112+ if ( needs_sudo ) {
113+ args = [
113114 "pkgx" ,
114115 "deno^2.1" ,
115116 "run" ,
@@ -119,14 +120,14 @@ async function install(args: string[]) {
119120 self ,
120121 "sudo-install" ,
121122 pkgx_dir ,
122- ...to_install ,
123- ] ,
124- env ,
125- clearEnv : true ,
126- } )
127- . spawn ( ) . status ;
128-
129- Deno . exit ( status . code ) ;
123+ ...to_install
124+ ] ;
125+ const cmd = "/usr/bin/sudo" ;
126+ const status = await new Deno . Command ( cmd , { args , env , clearEnv : true } ) . spawn ( ) . status ;
127+ Deno . exit ( status . code ) ;
128+ } else {
129+ await sudo_install ( pkgx_dir , to_install ) ;
130+ }
130131}
131132
132133async function sudo_install ( pkgx_dir : string , pkg_prefixes : string [ ] ) {
You can’t perform that action at this time.
0 commit comments