1- #!/usr/bin/env -S pkgx deno^2.1 run --ext=ts --allow-sys=uid --allow-run=pkgx,/usr/bin/sudo --allow-env=PKGX_DIR,HOME --allow-read=/usr/local/pkgs
1+ #!/usr/bin/env -S pkgx deno^2.1 run --ext=ts --allow-sys=uid --allow-run=pkgx,/usr/bin/sudo --allow-env=PKGX_DIR,HOMEBREW_PREFIX, HOME --allow-read=/usr/local/pkgs
22import { dirname , fromFileUrl , join } from "jsr:@std/path@^1" ;
33import { ensureDir , existsSync } from "jsr:@std/fs@^1" ;
44import { parse as parse_args } from "jsr:@std/flags@0.224.0" ;
55import * as semver from "jsr:@std/semver@^1" ;
66
7+ const standardPath = ( ( ) => {
8+ const basePath = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" ;
9+ const homebrew = `${ Deno . env . get ( "HOMEBREW_PREFIX" ) || "/opt/homebrew" } /bin` ;
10+ if ( existsSync ( homebrew ) ) {
11+ return `${ homebrew } :${ basePath } ` ;
12+ } else {
13+ return basePath ;
14+ }
15+ } ) ( ) ;
16+
717const parsedArgs = parse_args ( Deno . args , {
818 alias : {
919 v : "version" ,
@@ -18,7 +28,7 @@ if (parsedArgs.help) {
1828 args : [ "gh" , "repo" , "view" , "pkgxdev/pkgm" ] ,
1929 clearEnv : true ,
2030 env : {
21- "PATH" : "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" ,
31+ "PATH" : standardPath ,
2232 "HOME" : Deno . env . get ( "HOME" ) ! ,
2333 } ,
2434 } ) . spawn ( ) . status ;
@@ -69,7 +79,7 @@ async function install(args: string[]) {
6979 args = args . map ( ( x ) => `+${ x } ` ) ;
7080
7181 const env : Record < string , string > = {
72- "PATH" : "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" ,
82+ "PATH" : standardPath ,
7383 } ;
7484 const set = ( key : string ) => {
7585 const x = Deno . env . get ( key ) ;
0 commit comments