FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
evolution-api/runWithProvider.js at develop · rafwell/evolution-api · GitHub
rafwell
/
evolution-api
Public
forked from
evolution-foundation/evolution-api
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
evolution-api
/
runWithProvider.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (43 loc) · 1.63 KB
Breadcrumbs
evolution-api
/
runWithProvider.js
Copy path
File metadata and controls
52 lines (43 loc) · 1.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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'
;
if
(
!
DATABASE_PROVIDER
)
{
console
.
warn
(
`DATABASE_PROVIDER is not set in the .env file, using default:
${
databaseProviderDefault
}
`
)
;
}
// Função para determinar qual pasta de migrations usar
// Função para determinar qual pasta de migrations usar
function
getMigrationsFolder
(
provider
)
{
switch
(
provider
)
{
case
'psql_bouncer'
:
return
'postgresql-migrations'
;
// psql_bouncer usa as migrations do postgresql
default
:
return
`
${
provider
}
-migrations`
;
}
}
const
migrationsFolder
=
getMigrationsFolder
(
databaseProviderDefault
)
;
let
command
=
process
.
argv
.
slice
(
2
)
.
join
(
' '
)
.
replace
(
/
D
A
T
A
B
A
S
E
_
P
R
O
V
I
D
E
R
/
g
,
databaseProviderDefault
)
;
// Substituir referências à pasta de migrations pela pasta correta
const
migrationsPattern
=
new
RegExp
(
`
${
databaseProviderDefault
}
-migrations`
,
'g'
)
;
command
=
command
.
replace
(
migrationsPattern
,
migrationsFolder
)
;
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'
}
)
;
}
catch
(
error
)
{
console
.
error
(
`Error executing command:
${
command
}
`
)
;
process
.
exit
(
1
)
;
}
Back
|
FazBrowse Home
|
New Git URL