File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,26 @@ switch (Deno.args[0]) {
2424
2525const snuff = await sniff ( Path . cwd ( ) ) ;
2626
27+ if ( snuff . pkgs . length === 0 && Object . keys ( snuff . env ) . length === 0 ) {
28+ console . error ( "no devenv detected" ) ;
29+ Deno . exit ( 1 ) ;
30+ }
31+
32+ let env = '' ;
2733const pkgspecs = snuff . pkgs . map ( ( pkg ) => `+${ utils . pkg . str ( pkg ) } ` ) ;
2834
29- const cmd = new Deno . Command ( "pkgx" , {
30- args : [ ...pkgspecs ] ,
31- stdout : "piped" ,
32- env : { CLICOLOR_FORCE : "1" } , // unfortunate
33- } ) . spawn ( ) ;
35+ if ( snuff . pkgs . length > 0 ) {
36+ const cmd = new Deno . Command ( "pkgx" , {
37+ args : [ ...pkgspecs ] ,
38+ stdout : "piped" ,
39+ env : { CLICOLOR_FORCE : "1" } , // unfortunate
40+ } ) . spawn ( ) ;
3441
35- await cmd . status ;
42+ await cmd . status ;
3643
37- const stdout = ( await cmd . output ( ) ) . stdout ;
38- let env = new TextDecoder ( ) . decode ( stdout ) ;
44+ const stdout = ( await cmd . output ( ) ) . stdout ;
45+ env = new TextDecoder ( ) . decode ( stdout ) ;
46+ }
3947
4048// add any additional env that we sniffed
4149for ( const [ key , value ] of Object . entries ( snuff . env ) ) {
@@ -46,8 +54,11 @@ env = env.trim();
4654
4755let undo = "" ;
4856for ( const envln of env . trim ( ) . split ( "\n" ) ) {
57+ if ( ! envln ) continue ;
58+
4959 const [ key ] = envln . split ( "=" , 2 ) ;
5060 const value = Deno . env . get ( key ) ;
61+
5162 if ( value ) {
5263 undo += ` export ${ key } =${ shell_escape ( value ) } \n` ;
5364 } else {
You can’t perform that action at this time.
0 commit comments