Skip to content

Commit

Permalink
Merge pull request #82 from AthennaIO/develop
Browse files Browse the repository at this point in the history
fix(types): add command input/output types
  • Loading branch information
jlenon7 committed Sep 24, 2023
2 parents 86e37fc + dbb2bb0 commit 47bb62b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 21 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/common",
"version": "4.15.0",
"version": "4.15.1",
"description": "The Athenna common helpers to use in any Node.js ESM project.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
25 changes: 12 additions & 13 deletions src/helpers/Exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ import { File } from '#src/helpers/File'
import { Options } from '#src/helpers/Options'
import { request as requestHttp } from 'node:http'
import { request as requestHttps } from 'node:https'
import type { PaginationOptions, PaginatedResponse } from '#src/types'
import {
execa,
execaNode,
execaCommand,
type Options as CommandOptions,
type NodeOptions as NodeCommandOptions,
type ExecaChildProcess as CommandOutput
} from 'execa'
import { execa, execaNode, execaCommand } from 'execa'
import type {
CommandInput,
CommandOutput,
NodeCommandInput,
PaginationOptions,
PaginatedResponse
} from '#src/types'

export class Exec {
/**
Expand All @@ -47,7 +46,7 @@ export class Exec {
*/
public static async shell(
command: string,
options: CommandOptions = {}
options: CommandInput = {}
): Promise<CommandOutput> {
return execa('sh', ['-c', command], options)
}
Expand All @@ -57,7 +56,7 @@ export class Exec {
*/
public static async command(
command: string,
options: CommandOptions = {}
options: CommandInput = {}
): Promise<CommandOutput> {
return execaCommand(command, options)
}
Expand All @@ -68,7 +67,7 @@ export class Exec {
public static async node(
path: string,
argv: string[] = [],
options: NodeCommandOptions = {}
options: NodeCommandInput = {}
): Promise<CommandOutput> {
return execaNode(path, argv, options)
}
Expand All @@ -78,7 +77,7 @@ export class Exec {
*/
public static async artisan(
path: string,
options: NodeCommandOptions = {}
options: NodeCommandInput = {}
): Promise<void> {
options = Options.create(options, {
preferLocal: true,
Expand Down
12 changes: 12 additions & 0 deletions src/types/CommandInput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @athenna/common
*
* (c) João Lenon <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import type { Options } from 'execa'

export type CommandInput = Options
8 changes: 3 additions & 5 deletions src/types/CommandOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* file that was distributed with this source code.
*/

export type CommandOutput = {
stdout: string
stderr: string
exitCode: number
}
import type { ExecaChildProcess } from 'execa'

export type CommandOutput = ExecaChildProcess
12 changes: 12 additions & 0 deletions src/types/NodeCommandInput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @athenna/common
*
* (c) João Lenon <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import type { NodeOptions } from 'execa'

export type NodeCommandInput = NodeOptions
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export type {
export * from '#src/types/Merge'
export * from '#src/types/Except'
export * from '#src/types/PathDirs'
export * from '#src/types/CommandInput'
export * from '#src/types/CommandOutput'
export * from '#src/types/NodeCommandInput'
export * from '#src/types/ObjectBuilderOptions'

export * from '#src/types/json/FileJson'
Expand Down

0 comments on commit 47bb62b

Please sign in to comment.