From 2125e2d084e5af08a2c74f7998c5af5abf8e5408 Mon Sep 17 00:00:00 2001 From: haricnugraha Date: Fri, 4 Oct 2024 16:04:43 +0700 Subject: [PATCH] revert: unnecessary code changes --- bin/dev.cmd | 3 ++- bin/dev.js | 8 ++++---- bin/run.js | 6 +++++- src/utils/http.ts | 10 ++++------ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/bin/dev.cmd b/bin/dev.cmd index 077b57ae7..2a77e14c6 100644 --- a/bin/dev.cmd +++ b/bin/dev.cmd @@ -1,3 +1,4 @@ + @echo off -node "%~dp0\dev" %* \ No newline at end of file +node "%~dp0\dev" %* diff --git a/bin/dev.js b/bin/dev.js index 3d7161eba..cbb8ea019 100755 --- a/bin/dev.js +++ b/bin/dev.js @@ -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}) })() \ No newline at end of file diff --git a/bin/run.js b/bin/run.js index 6fc5cb695..8c442ce34 100755 --- a/bin/run.js +++ b/bin/run.js @@ -1,3 +1,7 @@ #!/usr/bin/env node -require('../lib').run().catch(require('@oclif/core/handle')) \ No newline at end of file +// eslint-disable-next-line unicorn/prefer-top-level-await +(async () => { + const oclif = await import('@oclif/core') + await oclif.execute({development: false, dir: __dirname}) + })() \ No newline at end of file diff --git a/src/utils/http.ts b/src/utils/http.ts index 8772a137d..af6d86f2b 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -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' @@ -49,14 +49,12 @@ const axiosInstance = axios.create() export async function sendHttpRequest( config: HttpRequestParams ): Promise { - 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 @@ -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) {