Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CRA to Vite Migration Script
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zandor Smith
CRA to Vite Migration Script
Commits
6c708be2
Verified
Commit
6c708be2
authored
11 months ago
by
Zandor Smith
Browse files
Options
Downloads
Patches
Plain Diff
Code style improvement of script 4.
parent
40f6f91e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/steps/04-rename-variables.mjs
+22
-21
22 additions, 21 deletions
src/steps/04-rename-variables.mjs
with
22 additions
and
21 deletions
src/steps/04-rename-variables.mjs
+
22
−
21
View file @
6c708be2
...
...
@@ -18,28 +18,29 @@ async function processFilesInDirectory(directory) {
continue
;
}
if
(
file
.
isFile
())
{
con
st
filePath
=
`
${
directory
}${
file
.
name
}
`
;
let
fileContent
=
fs
.
readFileSync
(
filePath
,
"
utf8
"
);
let
madeChanges
=
false
;
if
(
fileContent
.
includes
(
"
REACT_APP_
"
))
{
console
.
log
(
"
Replace 'REACT_APP_' with 'VITE_' in
"
,
filePath
);
fileContent
=
fileContent
.
replaceAll
(
"
REACT_APP_
"
,
"
VITE_
"
);
madeChanges
=
true
;
}
if
((
filePath
.
endsWith
(
"
.js
"
)
||
filePath
.
endsWith
(
"
.jsx
"
))
&&
fileContent
.
includes
(
"
process.env
"
))
{
console
.
log
(
"
Replace 'process.env' with 'import.meta.env' in
"
,
filePath
);
fileContent
=
fileContent
.
replaceAll
(
"
process.env
"
,
"
import.meta.env
"
);
madeChanges
=
true
;
}
if
(
!
madeChanges
)
{
continue
;
}
fs
.
writeFileSync
(
filePath
,
fileContent
)
;
if
(
!
file
.
isFile
())
{
con
tinue
;
}
const
filePath
=
`
${
directory
}${
file
.
name
}
`
;
let
fileContent
=
fs
.
readFileSync
(
filePath
,
"
utf8
"
);
let
madeChanges
=
false
;
if
(
fileContent
.
includes
(
"
REACT_APP_
"
))
{
console
.
log
(
"
Replace 'REACT_APP_' with 'VITE_' in
"
,
filePath
)
;
fileContent
=
fileContent
.
replaceAll
(
"
REACT_APP_
"
,
"
VITE_
"
);
madeChanges
=
true
;
}
if
((
filePath
.
endsWith
(
"
.js
"
)
||
filePath
.
endsWith
(
"
.jsx
"
))
&&
fileContent
.
includes
(
"
process.env
"
))
{
console
.
log
(
"
Replace 'process.env' with 'import.meta.env' in
"
,
filePath
)
;
fileContent
=
fileContent
.
replaceAll
(
"
process.env
"
,
"
import.meta.env
"
);
madeChanges
=
true
;
}
if
(
!
madeChanges
)
{
continue
;
}
fs
.
writeFileSync
(
filePath
,
fileContent
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment