UNPKG

axios-mock-server

Version:
29 lines 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var moduleName = "'axios-mock-server'"; var eslintComment = '/* eslint-disable */'; var createImportPath = function (filePath, inputDir) { return filePath .replace(new RegExp("^(.\\/)?" + inputDir.replace(/^.\//, '').replace(/\/$/, '')), '') .replace(/\.(ts|js)$/, ''); }; var createCondition = function (filePath, inputDir, methods) { return "\n {\n path: '" + (createImportPath(filePath, inputDir).replace(/(\/index)$/, '') || '/') + "',\n methods: " + methods + "\n }"; }; exports.default = (function (inputDir, target, isTS, pathList, baseURL) { if (baseURL === void 0) { baseURL = ''; } return target === 'es6' ? eslintComment + "\n" + (isTS ? "import { AxiosInstance } from 'axios'\n" : '') + "import mockServer from " + moduleName + "\n" + pathList .map(function (filePath, i) { return "import mock" + i + " from '." + createImportPath(filePath, inputDir) + "'\n"; }) .join('') + "\nexport default (client" + (isTS ? '?: AxiosInstance' : '') + ") => mockServer([" + pathList .map(function (filePath, i) { return createCondition(filePath, inputDir, "mock" + i); }) .join(',') + "\n], client, '" + baseURL + "')\n" : eslintComment + "\n" + (isTS ? "import { AxiosInstance } = require('axios')\n" : '') + "module.exports = (client" + (isTS ? '?: AxiosInstance' : '') + ") => require(" + moduleName + ")([" + pathList .map(function (filePath) { return createCondition(filePath, inputDir, "require('." + createImportPath(filePath, inputDir) + "')"); }) .join(',') + "\n], client, '" + baseURL + "')\n"; }); //# sourceMappingURL=createRouteString.js.map