mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-18 19:32:21 -06:00
Add Windows support for database deployment and improve error handling in runWithProvider.js
This commit is contained in:
@@ -1,19 +1,31 @@
|
||||
const dotenv = require('dotenv');
|
||||
const { execSync } = require('child_process');
|
||||
const { existsSync } = require('fs');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const { DATABASE_PROVIDER } = process.env;
|
||||
const databaseProviderDefault = DATABASE_PROVIDER ?? "postgresql"
|
||||
const databaseProviderDefault = DATABASE_PROVIDER ?? 'postgresql';
|
||||
|
||||
if (!DATABASE_PROVIDER) {
|
||||
console.error(`DATABASE_PROVIDER is not set in the .env file, using default: ${databaseProviderDefault}`);
|
||||
// process.exit(1);
|
||||
console.warn(`DATABASE_PROVIDER is not set in the .env file, using default: ${databaseProviderDefault}`);
|
||||
}
|
||||
|
||||
const command = process.argv
|
||||
let command = process.argv
|
||||
.slice(2)
|
||||
.join(' ')
|
||||
.replace(/\DATABASE_PROVIDER/g, databaseProviderDefault);
|
||||
.replace(/DATABASE_PROVIDER/g, databaseProviderDefault);
|
||||
|
||||
if (command.includes('rmdir') && existsSync('prisma\\migrations')) {
|
||||
try {
|
||||
execSync('rmdir /S /Q prisma\\migrations', { stdio: 'inherit' });
|
||||
} catch (error) {
|
||||
console.error(`Error removing directory: prisma\\migrations`);
|
||||
process.exit(1);
|
||||
}
|
||||
} else if (command.includes('rmdir')) {
|
||||
console.warn(`Directory 'prisma\\migrations' does not exist, skipping removal.`);
|
||||
}
|
||||
|
||||
try {
|
||||
execSync(command, { stdio: 'inherit' });
|
||||
|
||||
Reference in New Issue
Block a user