mirror of
https://github.com/kekxv/AiReviewPR.git
synced 2025-02-11 22:41:50 +01:00
fix
This commit is contained in:
17
dist/utils.js
vendored
17
dist/utils.js
vendored
@@ -7,14 +7,19 @@ exports.post = exports.doesAnyPatternMatch = exports.split_message = void 0;
|
||||
const http_1 = __importDefault(require("http"));
|
||||
const https_1 = __importDefault(require("https"));
|
||||
function split_message(files) {
|
||||
files = files || "";
|
||||
let n = files.includes('\n') || files.includes('\r');
|
||||
files = files.trim();
|
||||
if (!files) {
|
||||
let t = files.split("\n");
|
||||
if (t.length > 0)
|
||||
return t.map(str => str.trim()).filter(item => item !== null && item !== undefined && item !== "");
|
||||
return files.split(",").map(str => str.trim()).filter(item => item !== null && item !== undefined && item !== "");
|
||||
let res = [];
|
||||
if (files) {
|
||||
if (n) {
|
||||
res = files.split(/[\r\n]/);
|
||||
}
|
||||
else {
|
||||
res = files.split(",");
|
||||
}
|
||||
}
|
||||
return [];
|
||||
return res.map(str => str.trim()).filter(item => item !== null && item !== undefined && item !== "");
|
||||
}
|
||||
exports.split_message = split_message;
|
||||
function doesAnyPatternMatch(patterns, str) {
|
||||
|
||||
4
jest.config.js
Normal file
4
jest.config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
3854
package-lock.json
generated
3854
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -6,9 +6,10 @@
|
||||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^22.10.6",
|
||||
"jest": "^29.7.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"typescript": "^4.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
|
||||
17
src/utils.ts
17
src/utils.ts
@@ -1,14 +1,19 @@
|
||||
import http from "http";
|
||||
import https from "https";
|
||||
|
||||
export function split_message(files: string) {
|
||||
export function split_message(files: string): string[] {
|
||||
files = files || "";
|
||||
let n = files.includes('\n') || files.includes('\r');
|
||||
files = files.trim()
|
||||
if (!files) {
|
||||
let t = files.split("\n");
|
||||
if (t.length > 0) return t.map(str => str.trim()).filter(item => item !== null && item !== undefined && item !== "");
|
||||
return files.split(",").map(str => str.trim()).filter(item => item !== null && item !== undefined && item !== "")
|
||||
let res: string[] = [];
|
||||
if (files) {
|
||||
if (n) {
|
||||
res = files.split(/[\r\n]/);
|
||||
} else {
|
||||
res = files.split(",")
|
||||
}
|
||||
}
|
||||
return []
|
||||
return res.map(str => str.trim()).filter(item => item !== null && item !== undefined && item !== "")
|
||||
}
|
||||
|
||||
export function doesAnyPatternMatch(patterns: Array<string>, str: string) {
|
||||
|
||||
16
test/split_message.test.ts
Normal file
16
test/split_message.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// split_message.test.ts
|
||||
import {doesAnyPatternMatch, split_message} from '../src/utils';
|
||||
|
||||
describe('split_message', () => {
|
||||
it('include readme.md', () => {
|
||||
const testString = `^.+\\.md
|
||||
test2\\.js
|
||||
dist/.*
|
||||
|
||||
`;
|
||||
expect(doesAnyPatternMatch(split_message(testString),"readme.md")).toBe(true);
|
||||
expect(doesAnyPatternMatch(split_message(testString),"dist/index.js")).toBe(true);
|
||||
expect(doesAnyPatternMatch(split_message(testString),"dist/prompt.js")).toBe(true);
|
||||
expect(doesAnyPatternMatch(split_message(testString),"src/index.js")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -5,7 +5,8 @@
|
||||
"node_modules/@types"
|
||||
],
|
||||
"types": [
|
||||
"node"
|
||||
"node",
|
||||
"jest"
|
||||
],
|
||||
"target": "ES2020",
|
||||
// 编译目标
|
||||
@@ -30,4 +31,4 @@
|
||||
"**/*.spec.ts"
|
||||
// 排除测试文件
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user