Skip to content

Commit 356112f

Browse files
committed
chore: Convert null values to empty strings in executor task
1 parent 77338cf commit 356112f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/_common/tasks/executor.task.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,35 @@ import { ExecutorResponseInterface } from '../interfaces/executor-response.inter
44
import { ExecutorConfigInterface } from '../interfaces/executor-config.interface';
55
import { join } from 'path';
66

7+
function convertNullToEmptyString(obj) {
8+
if (obj === null) {
9+
return "";
10+
}
11+
12+
if (Array.isArray(obj)) {
13+
return obj.map(convertNullToEmptyString);
14+
}
15+
16+
if (typeof obj === 'object') {
17+
const newObj = {};
18+
for (const key in obj) {
19+
if (obj.hasOwnProperty(key)) {
20+
newObj[key] = convertNullToEmptyString(obj[key]);
21+
}
22+
}
23+
return newObj;
24+
}
25+
26+
return obj;
27+
}
28+
729
export async function executorTask(
830
command: string,
931
job: Job,
1032
options?: ExecutorConfigInterface,
1133
): Promise<ExecutorResponseInterface> {
1234
return new Promise((resolve, reject) => {
13-
const jobDataArg = JSON.stringify(job.data);
35+
const jobDataArg = JSON.stringify(convertNullToEmptyString(job.data));
1436
// const escapedJobDataArg = `'${jobDataArg.replace(/'/g, "'\\''")}'`;
1537

1638
try {

0 commit comments

Comments
 (0)