bun-scripty
Advanced tools
Comparing version 1.0.2 to 1.0.3
#!/usr/bin/env bun | ||
// @bun | ||
var{file:p}=globalThis.Bun;class o extends Error{constructor(e){super(`Environment variable '${e}' is not defined`);this.name="EnvVarNotDefinedError"}}var r=(...e)=>e.join("/").replace(/\/+/g,"/");var c=async()=>{const{npm_config_local_prefix:e,npm_package_json:t,npm_lifecycle_event:n}=process.env;if(!n)throw new o("npm_lifecycle_event");if(!t)throw new o("npm_package_json");if(!e)throw new o("npm_config_local_prefix");if(!await import(t))throw new Error("Failed to import package.json");const s=n.replaceAll(":","/"),a=r(e,"scripts");return{named:r(a,`${s}.ts`),indexed:r(a,s,"index.ts")}};try{const e=await c(),t=["bun","run"];if(await p(e.named).exists())t.push(e.named);else if(await p(e.indexed).exists())t.push(e.indexed);else throw new Error(`No script file found at ${e.named} or ${e.indexed}`);const n=Bun.spawn(t),i=await new Response(n.stdout).text();console.log(i),await n.exited}catch(e){console.error(e)}export{c as mapScriptPathSegmentToFilePaths}; | ||
var{file:d}=globalThis.Bun;var c=async({named:t,indexed:e})=>{for(let r of[t,e])if(await d(r).exists())return r;throw new Error(`No script file found at ${t} or ${e}`)};class o extends Error{constructor(t){super(`Environment variable '${t}' is not defined`);this.name="EnvVarNotDefinedError"}}var i=(...t)=>t.join("/").replace(/\/+/g,"/");var m=async()=>{const{npm_config_local_prefix:t,npm_package_json:e,npm_lifecycle_event:r}=process.env;if(!r)throw new o("npm_lifecycle_event");if(!e)throw new o("npm_package_json");if(!t)throw new o("npm_config_local_prefix");if(!await import(e))throw new Error("Failed to import package.json");const n=r.replaceAll(":","/"),s=i(t,"scripts");return{named:i(s,`${n}.ts`),indexed:i(s,n,"index.ts")}};var p=(t,e)=>{const r=t.getReader(),a=async()=>{const{done:n,value:s}=await r.read();if(n){console.log(`${e===process.stdout?"stdout":"stderr"} complete`);return}e.write(s),await a()};a()};var{spawn:l}=globalThis.Bun;var f=(t)=>l(["bun","run",t],{stdout:"pipe",stderr:"pipe"});try{const t=await m().then(c).then(f);p(t.stdout,process.stdout),p(t.stderr,process.stderr);const e=await t.exited;console.log(`Process exited with code ${e}`)}catch(t){console.error(t)}export{m as mapScriptPathSegmentToFilePaths}; |
#!/usr/bin/env bun | ||
// @bun | ||
var{file:p}=globalThis.Bun;class o extends Error{constructor(e){super(`Environment variable '${e}' is not defined`);this.name="EnvVarNotDefinedError"}}var r=(...e)=>e.join("/").replace(/\/+/g,"/");var c=async()=>{const{npm_config_local_prefix:e,npm_package_json:t,npm_lifecycle_event:n}=process.env;if(!n)throw new o("npm_lifecycle_event");if(!t)throw new o("npm_package_json");if(!e)throw new o("npm_config_local_prefix");if(!await import(t))throw new Error("Failed to import package.json");const s=n.replaceAll(":","/"),a=r(e,"scripts");return{named:r(a,`${s}.ts`),indexed:r(a,s,"index.ts")}};try{const e=await c(),t=["bun","run"];if(await p(e.named).exists())t.push(e.named);else if(await p(e.indexed).exists())t.push(e.indexed);else throw new Error(`No script file found at ${e.named} or ${e.indexed}`);const n=Bun.spawn(t),i=await new Response(n.stdout).text();console.log(i),await n.exited}catch(e){console.error(e)}export{c as mapScriptPathSegmentToFilePaths}; | ||
var{file:d}=globalThis.Bun;var c=async({named:t,indexed:e})=>{for(let r of[t,e])if(await d(r).exists())return r;throw new Error(`No script file found at ${t} or ${e}`)};class o extends Error{constructor(t){super(`Environment variable '${t}' is not defined`);this.name="EnvVarNotDefinedError"}}var i=(...t)=>t.join("/").replace(/\/+/g,"/");var m=async()=>{const{npm_config_local_prefix:t,npm_package_json:e,npm_lifecycle_event:r}=process.env;if(!r)throw new o("npm_lifecycle_event");if(!e)throw new o("npm_package_json");if(!t)throw new o("npm_config_local_prefix");if(!await import(e))throw new Error("Failed to import package.json");const n=r.replaceAll(":","/"),s=i(t,"scripts");return{named:i(s,`${n}.ts`),indexed:i(s,n,"index.ts")}};var p=(t,e)=>{const r=t.getReader(),a=async()=>{const{done:n,value:s}=await r.read();if(n){console.log(`${e===process.stdout?"stdout":"stderr"} complete`);return}e.write(s),await a()};a()};var{spawn:l}=globalThis.Bun;var f=(t)=>l(["bun","run",t],{stdout:"pipe",stderr:"pipe"});try{const t=await m().then(c).then(f);p(t.stdout,process.stdout),p(t.stderr,process.stderr);const e=await t.exited;console.log(`Process exited with code ${e}`)}catch(t){console.error(t)}export{m as mapScriptPathSegmentToFilePaths}; |
#!/usr/bin/env bun | ||
// @bun | ||
var{file:p}=globalThis.Bun;class o extends Error{constructor(e){super(`Environment variable '${e}' is not defined`);this.name="EnvVarNotDefinedError"}}var r=(...e)=>e.join("/").replace(/\/+/g,"/");var c=async()=>{const{npm_config_local_prefix:e,npm_package_json:t,npm_lifecycle_event:n}=process.env;if(!n)throw new o("npm_lifecycle_event");if(!t)throw new o("npm_package_json");if(!e)throw new o("npm_config_local_prefix");if(!await import(t))throw new Error("Failed to import package.json");const s=n.replaceAll(":","/"),a=r(e,"scripts");return{named:r(a,`${s}.ts`),indexed:r(a,s,"index.ts")}};try{const e=await c(),t=["bun","run"];if(await p(e.named).exists())t.push(e.named);else if(await p(e.indexed).exists())t.push(e.indexed);else throw new Error(`No script file found at ${e.named} or ${e.indexed}`);const n=Bun.spawn(t),i=await new Response(n.stdout).text();console.log(i),await n.exited}catch(e){console.error(e)}export{c as mapScriptPathSegmentToFilePaths}; | ||
var{file:d}=globalThis.Bun;var c=async({named:t,indexed:e})=>{for(let r of[t,e])if(await d(r).exists())return r;throw new Error(`No script file found at ${t} or ${e}`)};class o extends Error{constructor(t){super(`Environment variable '${t}' is not defined`);this.name="EnvVarNotDefinedError"}}var i=(...t)=>t.join("/").replace(/\/+/g,"/");var m=async()=>{const{npm_config_local_prefix:t,npm_package_json:e,npm_lifecycle_event:r}=process.env;if(!r)throw new o("npm_lifecycle_event");if(!e)throw new o("npm_package_json");if(!t)throw new o("npm_config_local_prefix");if(!await import(e))throw new Error("Failed to import package.json");const n=r.replaceAll(":","/"),s=i(t,"scripts");return{named:i(s,`${n}.ts`),indexed:i(s,n,"index.ts")}};var p=(t,e)=>{const r=t.getReader(),a=async()=>{const{done:n,value:s}=await r.read();if(n){console.log(`${e===process.stdout?"stdout":"stderr"} complete`);return}e.write(s),await a()};a()};var{spawn:l}=globalThis.Bun;var f=(t)=>l(["bun","run",t],{stdout:"pipe",stderr:"pipe"});try{const t=await m().then(c).then(f);p(t.stdout,process.stdout),p(t.stderr,process.stderr);const e=await t.exited;console.log(`Process exited with code ${e}`)}catch(t){console.error(t)}export{m as mapScriptPathSegmentToFilePaths}; |
#!/usr/bin/env bun | ||
// @bun | ||
var{file:p}=globalThis.Bun;class o extends Error{constructor(e){super(`Environment variable '${e}' is not defined`);this.name="EnvVarNotDefinedError"}}var r=(...e)=>e.join("/").replace(/\/+/g,"/");var c=async()=>{const{npm_config_local_prefix:e,npm_package_json:t,npm_lifecycle_event:n}=process.env;if(!n)throw new o("npm_lifecycle_event");if(!t)throw new o("npm_package_json");if(!e)throw new o("npm_config_local_prefix");if(!await import(t))throw new Error("Failed to import package.json");const s=n.replaceAll(":","/"),a=r(e,"scripts");return{named:r(a,`${s}.ts`),indexed:r(a,s,"index.ts")}};try{const e=await c(),t=["bun","run"];if(await p(e.named).exists())t.push(e.named);else if(await p(e.indexed).exists())t.push(e.indexed);else throw new Error(`No script file found at ${e.named} or ${e.indexed}`);const n=Bun.spawn(t),i=await new Response(n.stdout).text();console.log(i),await n.exited}catch(e){console.error(e)}export{c as mapScriptPathSegmentToFilePaths}; | ||
var{file:d}=globalThis.Bun;var c=async({named:t,indexed:e})=>{for(let r of[t,e])if(await d(r).exists())return r;throw new Error(`No script file found at ${t} or ${e}`)};class o extends Error{constructor(t){super(`Environment variable '${t}' is not defined`);this.name="EnvVarNotDefinedError"}}var i=(...t)=>t.join("/").replace(/\/+/g,"/");var m=async()=>{const{npm_config_local_prefix:t,npm_package_json:e,npm_lifecycle_event:r}=process.env;if(!r)throw new o("npm_lifecycle_event");if(!e)throw new o("npm_package_json");if(!t)throw new o("npm_config_local_prefix");if(!await import(e))throw new Error("Failed to import package.json");const n=r.replaceAll(":","/"),s=i(t,"scripts");return{named:i(s,`${n}.ts`),indexed:i(s,n,"index.ts")}};var p=(t,e)=>{const r=t.getReader(),a=async()=>{const{done:n,value:s}=await r.read();if(n){console.log(`${e===process.stdout?"stdout":"stderr"} complete`);return}e.write(s),await a()};a()};var{spawn:l}=globalThis.Bun;var f=(t)=>l(["bun","run",t],{stdout:"pipe",stderr:"pipe"});try{const t=await m().then(c).then(f);p(t.stdout,process.stdout),p(t.stderr,process.stderr);const e=await t.exited;console.log(`Process exited with code ${e}`)}catch(t){console.error(t)}export{m as mapScriptPathSegmentToFilePaths}; |
{ | ||
"name": "bun-scripty", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Scripty for Bun", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
11029
56