Skip to content

Commit

Permalink
revert: unnecessary code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
haricnugraha committed Oct 4, 2024
1 parent e6f3432 commit 2125e2d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

@echo off

node "%~dp0\dev" %*
node "%~dp0\dev" %*
8 changes: 4 additions & 4 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
// eslint-disable-next-line node/shebang
(async () => {
#!/usr/bin/env node_modules/.bin/ts-node
// eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await
;(async () => {
const oclif = await import('@oclif/core')
await oclif.execute({type: 'cjs', development: true, dir: __dirname})
await oclif.execute({development: true, dir: __dirname})
})()
6 changes: 5 additions & 1 deletion bin/run.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env node

require('../lib').run().catch(require('@oclif/core/handle'))
// eslint-disable-next-line unicorn/prefer-top-level-await
(async () => {
const oclif = await import('@oclif/core')
await oclif.execute({development: false, dir: __dirname})
})()
10 changes: 4 additions & 6 deletions src/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import type { AxiosRequestHeaders, AxiosResponse } from 'axios'
import axios from 'axios'
import http from 'node:http'
import https from 'node:https'
import { Agent } from 'undici'
import { Agent, type HeadersInit } from 'undici'

type HttpRequestParams = {
url: string
maxRedirects?: number
headers?: Headers
headers?: HeadersInit
timeout?: number
allowUnauthorizedSsl?: boolean
responseType?: 'stream'
Expand All @@ -49,14 +49,12 @@ const axiosInstance = axios.create()
export async function sendHttpRequest(
config: HttpRequestParams
): Promise<AxiosResponse> {
const { allowUnauthorizedSsl, body, headers, timeout, signal, ...options } =
config
const { allowUnauthorizedSsl, body, headers, timeout, ...options } = config

return axiosInstance.request({
...options,
data: body,
headers: convertHeadersToAxios(headers),
signal: signal as AbortSignal | undefined,
timeout: timeout ?? DEFAULT_TIMEOUT, // Ensure default timeout if not filled.
httpAgent,
httpsAgent: allowUnauthorizedSsl
Expand All @@ -65,7 +63,7 @@ export async function sendHttpRequest(
})
}

function convertHeadersToAxios(headersInit: Headers | undefined) {
function convertHeadersToAxios(headersInit: HeadersInit | undefined) {
const headers: AxiosRequestHeaders = {}

if (headersInit instanceof Headers) {
Expand Down

0 comments on commit 2125e2d

Please sign in to comment.