Skip to content

Commit 58e614c

Browse files
committed
fix(apigw): pascal api parameter error
1 parent bb6f7ad commit 58e614c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

jest.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ const config = {
2424
};
2525

2626
if (mod) {
27+
config.testPathIgnorePatterns = ['/node_modules/', '/__tests__/apigw/custom-domains.test.ts'];
2728
if (mod === 'custom-domains') {
2829
config.testRegex = `/__tests__/apigw/custom-domains.test.(js|ts)`;
2930
} else {
3031
if (mod.indexOf('.') !== -1) {
3132
const [moduleName, subModuleName] = mod.split('.');
3233
config.testRegex = `/__tests__/${moduleName}/${subModuleName}.test.(js|ts)`;
33-
config.testPathIgnorePatterns = ['/node_modules/'];
3434
} else {
3535
config.testRegex = `/__tests__/${process.env.MODULE}/.*.test.(js|ts)`;
36-
config.testPathIgnorePatterns = ['/node_modules/'];
3736
}
3837

3938
if (mod === 'scf') {

src/utils/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs';
22
import path from 'path';
33
import camelCase from 'camelcase';
4+
import { PascalCase } from 'type-fest';
45
import { CamelCasedProps, PascalCasedProps } from '../modules/interface';
56

67
// TODO: 将一些库换成 lodash
@@ -173,13 +174,20 @@ export function camelCaseProps<T>(obj: T): CamelCasedProps<T> {
173174
return res as CamelCasedProps<T>;
174175
}
175176

177+
export function pascalCase<T extends string>(str: T): PascalCase<T> {
178+
if (str.length <= 1) {
179+
return str.toUpperCase() as any;
180+
}
181+
return `${str[0].toUpperCase()}${str.slice(1)}` as any;
182+
}
183+
176184
export function pascalCaseProps<T>(obj: T): PascalCasedProps<T> {
177185
let res: Record<string, any> = {};
178186
if (isObject(obj)) {
179187
res = {} as any;
180188
Object.keys(obj).forEach((key: string) => {
181189
const val = (obj as any)[key];
182-
const k = camelCase(key, { pascalCase: true });
190+
const k = pascalCase(key);
183191
res[k] = isObject(val) || isArray(val) ? pascalCaseProps(val) : val;
184192
});
185193
}

0 commit comments

Comments
 (0)