File tree Expand file tree Collapse file tree 6 files changed +36
-18
lines changed
Expand file tree Collapse file tree 6 files changed +36
-18
lines changed Original file line number Diff line number Diff line change 1515 "url" : " https://github.com/cacjs/cac/issues"
1616 },
1717 "exports" : {
18- "." : " ./dist/index.mjs " ,
18+ "." : " ./dist/index.js " ,
1919 "./package.json" : " ./package.json"
2020 },
2121 "files" : [
Original file line number Diff line number Diff line change 66 type CommandExample ,
77 type HelpCallback ,
88} from './command.ts'
9- import { processArgs } from './node .ts'
9+ import { runtimeProcessArgs } from './runtime .ts'
1010import {
1111 camelcaseOptionName ,
1212 getFileName ,
@@ -172,14 +172,23 @@ export class CAC extends EventTarget {
172172 * Parse argv
173173 */
174174 parse (
175- argv : string [ ] = processArgs ,
175+ argv ? : string [ ] ,
176176 {
177177 run = true ,
178178 } : {
179179 /** Whether to run the action for matched command */
180180 run ?: boolean | undefined
181181 } = { } ,
182182 ) : ParsedArgv {
183+ if ( ! argv ) {
184+ if ( ! runtimeProcessArgs ) {
185+ throw new Error (
186+ 'No argv provided and runtime process argv is not available.' ,
187+ )
188+ }
189+ argv = runtimeProcessArgs
190+ }
191+
183192 this . rawArgs = argv
184193 if ( ! this . name ) {
185194 this . name = argv [ 1 ] ? getFileName ( argv [ 1 ] ) : 'cli'
Original file line number Diff line number Diff line change 1- import { platformInfo } from './node .ts'
1+ import { runtimeInfo } from './runtime .ts'
22import { Option , type OptionConfig } from './option.ts'
33import {
44 CACError ,
@@ -251,7 +251,7 @@ export class Command {
251251 const { name } = this . cli
252252 const { versionNumber } = this . cli . globalCommand
253253 if ( versionNumber ) {
254- console . info ( `${ name } /${ versionNumber } ${ platformInfo } ` )
254+ console . info ( `${ name } /${ versionNumber } ${ runtimeInfo } ` )
255255 }
256256 }
257257
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /* eslint-disable import/no-mutable-exports */
2+ export let runtimeProcessArgs : string [ ] | undefined
3+ export let runtimeInfo : string
4+
5+ if ( typeof process !== 'undefined' ) {
6+ let runtimeName : string
7+ if ( typeof Deno !== 'undefined' && typeof Deno . version ?. deno === 'string' ) {
8+ runtimeName = 'deno'
9+ } else if ( typeof Bun !== 'undefined' && typeof Bun . version === 'string' ) {
10+ runtimeName = 'bun'
11+ } else {
12+ runtimeName = 'node'
13+ }
14+ runtimeInfo = `${ process . platform } -${ process . arch } ${ runtimeName } -${ process . version } `
15+ runtimeProcessArgs = process . argv
16+ } else if ( typeof navigator === 'undefined' ) {
17+ runtimeInfo = `unknown`
18+ } else {
19+ runtimeInfo = `${ navigator . platform } ${ navigator . userAgent } `
20+ }
Original file line number Diff line number Diff line change 1- import { nodeLib } from 'tsdown-preset-sxzz'
1+ import { lib } from 'tsdown-preset-sxzz'
22
3- export default nodeLib (
3+ export default lib (
44 {
55 inlineDeps : [ 'mri' ] ,
66 } ,
You can’t perform that action at this time.
0 commit comments