Skip to content

Commit 2a02092

Browse files
fix: change execSync to execFileSync
1 parent 427c994 commit 2a02092

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/api/provider/sessions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Auth, ConfigService, ProviderSession } from '@config/env.config';
22
import { Logger } from '@config/logger.config';
33
import axios from 'axios';
4-
import { execSync } from 'child_process';
4+
import { execFileSync } from 'child_process';
55

66
type ResponseSuccess = { status: number; data?: any };
77
type ResponseProvider = Promise<[ResponseSuccess?, Error?]>;
@@ -36,7 +36,7 @@ export class ProviderFiles {
3636
} catch (error) {
3737
this.logger.error(['Failed to connect to the file server', error?.message, error?.stack]);
3838
const pid = process.pid;
39-
execSync(`kill -9 ${pid}`);
39+
execFileSync('kill', ['-9', `${pid}`]);
4040
}
4141
}
4242
}

src/api/services/monitor.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { CacheConf, Chatwoot, ConfigService, Database, DelInstance, ProviderSess
77
import { Logger } from '@config/logger.config';
88
import { INSTANCE_DIR, STORE_DIR } from '@config/path.config';
99
import { NotFoundException } from '@exceptions';
10-
import { execSync } from 'child_process';
10+
import { execFileSync } from 'child_process';
1111
import EventEmitter2 from 'eventemitter2';
1212
import { rmSync } from 'fs';
1313
import { join } from 'path';
@@ -168,7 +168,8 @@ export class WAMonitoringService {
168168

169169
public async cleaningStoreData(instanceName: string) {
170170
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED) {
171-
execSync(`rm -rf ${join(STORE_DIR, 'chatwoot', instanceName + '*')}`);
171+
const instancePath = join(STORE_DIR, 'chatwoot', `${instanceName}*`);
172+
execFileSync('rm', ['-rf', instancePath]);
172173
}
173174

174175
const instance = await this.prismaRepository.instance.findFirst({

0 commit comments

Comments
 (0)