Skip to content

Commit

Permalink
Merge pull request #62 from w3nder/main
Browse files Browse the repository at this point in the history
Check if directories exist, create them if not
  • Loading branch information
jrCleber authored Aug 13, 2023
2 parents c877554 + b1dcf05 commit 5877713
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/whatsapp/repository/repository.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { AuthRepository } from './auth.repository';
import { Auth, ConfigService, Database } from '../../config/env.config';
import { execSync } from 'child_process';
import { join } from 'path';
import { existsSync } from 'fs';

export class RepositoryBroker {
constructor(
Expand All @@ -76,18 +77,21 @@ export class RepositoryBroker {
private __init_repo_without_db__() {
if (!this.configService.get<Database>('DATABASE').ENABLED) {
const storePath = join(process.cwd(), 'store');
execSync(
`mkdir -p ${join(
storePath,
'auth',
this.configService.get<Auth>('AUTHENTICATION').TYPE,
)}`,
);
execSync(`mkdir -p ${join(storePath, 'chats')}`);
execSync(`mkdir -p ${join(storePath, 'contacts')}`);
execSync(`mkdir -p ${join(storePath, 'messages')}`);
execSync(`mkdir -p ${join(storePath, 'message-up')}`);
execSync(`mkdir -p ${join(storePath, 'webhook')}`);
const paths = [
join(storePath, 'auth', this.configService.get<Auth>('AUTHENTICATION').TYPE),
join(storePath, 'chats'),
join(storePath, 'contacts'),
join(storePath, 'messages'),
join(storePath, 'message-up'),
join(storePath, 'webhook'),
];

for (const path of paths) {
if (existsSync(path)) {
continue;
}
execSync(`mkdir -p ${path}`);
}
}
}
}

0 comments on commit 5877713

Please sign in to comment.