Skip to content

Commit 090fed8

Browse files
committed
chore: wip
1 parent c67fd68 commit 090fed8

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

storage/framework/core/actions/src/helpers/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function runAction(action: string, options?: ActionOptions): Promis
1919

2020
const opts = parseOptions()
2121
const path = p.relativeActionsPath(`${action}.ts`)
22-
const cmd = `bun --bun ${path} ${opts}`
22+
const cmd = `bun --bun ${path} ${opts}`.trimEnd()
2323
const optionsWithCwd = {
2424
cwd: options?.cwd || p.projectPath(),
2525
...options,

storage/framework/core/cli/src/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ export function cli(name?: string | CliOptions, options?: CliOptions) {
2929
return cli
3030
}
3131

32-
export function command(name: string, description: string, options?: CliOptions) {
33-
return cli(options).command(name, description)
34-
}
32+
// export function command(name: string, description: string, options?: CliOptions) {
33+
// return cli(options).command(name, description)
34+
// }

storage/framework/core/cli/src/parse.ts

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -107,46 +107,52 @@ interface CliOptions {
107107
[k: string]: string | boolean | number | undefined
108108
}
109109

110-
export function parseOptions(options?: CliOptions): object {
111-
if (!options) {
112-
options = {}
113-
const args = process.argv.slice(2)
114-
115-
for (let i = 0; i < args.length; i++) {
116-
const arg = args[i]
117-
118-
if (arg?.startsWith('--')) {
119-
const key = arg.substring(2) // remove the --
120-
const camelCaseKey = key.replace(/-([a-z])/gi, g => (g[1] ? g[1].toUpperCase() : '')) // convert kebab-case to camelCase
121-
122-
if (i + 1 < args.length && (args[i + 1] === 'true' || args[i + 1] === 'false')) { // if the next arg is a boolean
110+
export function parseOptions(options?: CliOptions): CliOptions | undefined {
111+
options = options || {}
112+
const args = process.argv.slice(2)
113+
114+
for (let i = 0; i < args.length; i++) {
115+
const arg = args[i]
116+
if (arg?.startsWith('--')) {
117+
const key = arg.substring(2) // remove the --
118+
const camelCaseKey = key.replace(
119+
/-([a-z])/gi,
120+
g => (g[1] ? g[1].toUpperCase() : ''), // convert kebab-case to camelCase
121+
)
122+
123+
if (i + 1 < args.length) { // if the next arg exists
124+
if (args[i + 1] === 'true' || args[i + 1] === 'false') { // if the next arg is a boolean
123125
options[camelCaseKey] = args[i + 1] === 'true' // set the value to the boolean
124126
i++
125127
}
126128
else {
127-
options[camelCaseKey] = true
129+
options[camelCaseKey] = args[i + 1]
130+
i++
128131
}
129132
}
133+
else {
134+
options[camelCaseKey] = true
135+
}
130136
}
131-
132-
return options
133137
}
134138

139+
// if options has no keys, return undefined, e.g. `buddy release`
140+
if (Object.keys(options).length === 0)
141+
return undefined
142+
135143
// convert the string 'true' or 'false' to a boolean
136144
Object.keys(options).forEach((key) => {
137-
let value
138-
if (options)
139-
value = options[key]
145+
if (!options)
146+
return
140147

141-
if (value === 'true' || value === 'false') {
142-
if (options)
143-
options[key] = value === 'true'
144-
}
148+
const value = options[key]
149+
150+
if (value === 'true' || value === 'false')
151+
options[key] = value === 'true'
145152
})
146153

147154
return options
148155
}
149-
150156
// interface BuddyOptions {
151157
// dryRun?: boolean
152158
// verbose?: boolean

0 commit comments

Comments
 (0)