Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
7ce4b6e0
Commit
7ce4b6e0
authored
8 years ago
by
Alice Rose
Committed by
Dan Abramov
8 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Check for presence of folders before continuing eject. Closes
#939
. (#951)
parent
8a5c50d9
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/react-scripts/scripts/eject.js
+24
-14
packages/react-scripts/scripts/eject.js
with
24 additions
and
14 deletions
+24
-14
packages/react-scripts/scripts/eject.js
+
24
-
14
View file @
7ce4b6e0
...
...
@@ -30,6 +30,25 @@ prompt(
var
ownPath
=
path
.
join
(
__dirname
,
'
..
'
);
var
appPath
=
path
.
join
(
ownPath
,
'
..
'
,
'
..
'
);
function
verifyAbsent
(
file
)
{
if
(
fs
.
existsSync
(
path
.
join
(
appPath
,
file
)))
{
console
.
error
(
'
`
'
+
file
+
'
` already exists in your app folder. We cannot
'
+
'
continue as you would lose all the changes in that file or directory.
'
+
'
Please move or delete it (maybe make a copy for backup) and run this
'
+
'
command again.
'
);
process
.
exit
(
1
);
}
}
var
folders
=
[
'
config
'
,
path
.
join
(
'
config
'
,
'
jest
'
),
'
scripts
'
];
var
files
=
[
path
.
join
(
'
config
'
,
'
env.js
'
),
path
.
join
(
'
config
'
,
'
paths.js
'
),
...
...
@@ -44,22 +63,13 @@ prompt(
];
// Ensure that the app folder is clean and we won't override any files
files
.
forEach
(
function
(
file
)
{
if
(
fs
.
existsSync
(
path
.
join
(
appPath
,
file
)))
{
console
.
error
(
'
`
'
+
file
+
'
` already exists in your app folder. We cannot
'
+
'
continue as you would lose all the changes in that file or directory.
'
+
'
Please delete it (maybe make a copy for backup) and run this
'
+
'
command again.
'
);
process
.
exit
(
1
);
}
});
folders
.
forEach
(
verifyAbsent
);
files
.
forEach
(
verifyAbsent
);
// Copy the files over
f
s
.
mkdirSync
(
path
.
join
(
appPath
,
'
config
'
));
fs
.
mkdirSync
(
path
.
join
(
appPath
,
'
config
'
,
'
jest
'
))
;
fs
.
mkdirSync
(
path
.
join
(
appPath
,
'
scripts
'
)
);
f
olders
.
forEach
(
function
(
folder
)
{
fs
.
mkdirSync
(
path
.
join
(
appPath
,
folder
))
}
);
console
.
log
();
console
.
log
(
cyan
(
'
Copying files into
'
+
appPath
));
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets