|
1 | 1 | import type { PrinterConfigs, PrinterOptions } from './types'; |
2 | 2 | import { type OpenAPILatest, OpenAPIVersion } from '../types/openapi'; |
3 | | -import { toRelative } from '../utils/path'; |
| 3 | +import { toImportPath } from '../utils/path'; |
4 | 4 | import { isString, isUndefined } from '../utils/type-is'; |
5 | 5 | import { Arg } from './Arg'; |
6 | 6 | import { Args } from './Args'; |
@@ -188,14 +188,16 @@ export class Printer { |
188 | 188 | private _printImports() { |
189 | 189 | const { |
190 | 190 | axiosImportName = '', |
191 | | - axiosImportFile = AXIOS_IMPORT_FILE, |
192 | | - axiosTypeImportFile = AXIOS_TYPE_IMPORT_FILE, |
| 191 | + axiosImportFile, |
| 192 | + axiosTypeImportFile, |
193 | 193 | axiosRequestConfigTypeName = AXIOS_QUEST_CONFIG_TYPE_NAME, |
194 | 194 | axiosResponseTypeName = AXIOS_PROMISE_TYPE_NAME, |
195 | 195 | } = this.options || {}; |
196 | | - const { file } = this.configs; |
197 | | - const importPath = toRelative(axiosImportFile, file); |
198 | | - const importTypePath = toRelative(axiosTypeImportFile, file); |
| 196 | + const { cwd = '/', file } = this.configs; |
| 197 | + const axiosImportFile2 = axiosImportFile || AXIOS_IMPORT_FILE; |
| 198 | + const importPath = toImportPath(axiosImportFile2, cwd, file); |
| 199 | + const axiosTypeImportFile2 = axiosTypeImportFile || axiosImportFile || AXIOS_TYPE_IMPORT_FILE; |
| 200 | + const importTypePath = toImportPath(axiosTypeImportFile2, cwd, file); |
199 | 201 |
|
200 | 202 | return [ |
201 | 203 | toImportString(AXIOS_IMPORT_NAME, axiosImportName, importPath), |
|
0 commit comments