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
270fe06c
Commit
270fe06c
authored
8 years ago
by
Dan Abramov
Committed by
GitHub
8 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Catch synchronous errors from spawning yarn (#1204)
* Catch synchronous errors from spawning yarn * Fix issues
parent
0a9865db
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/create-react-app/index.js
+30
-19
packages/create-react-app/index.js
with
30 additions
and
19 deletions
+30
-19
packages/create-react-app/index.js
+
30
-
19
View file @
270fe06c
...
...
@@ -108,37 +108,48 @@ function createApp(name, verbose, version) {
}
function
install
(
packageToInstall
,
verbose
,
callback
)
{
var
args
=
[
function
fallbackToNpm
()
{
var
npmArgs
=
[
'
install
'
,
verbose
&&
'
--verbose
'
,
'
--save-dev
'
,
'
--save-exact
'
,
packageToInstall
,
].
filter
(
function
(
e
)
{
return
e
;
});
var
npmProc
=
spawn
(
'
npm
'
,
npmArgs
,
{
stdio
:
'
inherit
'
});
npmProc
.
on
(
'
close
'
,
function
(
code
)
{
callback
(
code
,
'
npm
'
,
npmArgs
);
});
}
var
yarnArgs
=
[
'
add
'
,
'
--dev
'
,
'
--exact
'
,
packageToInstall
,
];
var
proc
=
spawn
(
'
yarn
'
,
args
,
{
stdio
:
'
inherit
'
});
var
yarnProc
;
var
yarnExists
=
true
;
proc
.
on
(
'
error
'
,
function
(
err
)
{
try
{
yarnProc
=
spawn
(
'
yarn
'
,
yarnArgs
,
{
stdio
:
'
inherit
'
});
}
catch
(
err
)
{
// It's not clear why we end up here in some cases but we need this.
// https://github.com/facebookincubator/create-react-app/issues/1200
yarnExists
=
false
;
fallbackToNpm
();
return
;
}
yarnProc
.
on
(
'
error
'
,
function
(
err
)
{
if
(
err
.
code
===
'
ENOENT
'
)
{
yarnExists
=
false
;
}
});
p
roc
.
on
(
'
close
'
,
function
(
code
)
{
yarnP
roc
.
on
(
'
close
'
,
function
(
code
)
{
if
(
yarnExists
)
{
callback
(
code
,
'
yarn
'
,
args
);
return
;
callback
(
code
,
'
yarn
'
,
yarnArgs
);
}
else
{
fallbackToNpm
();
}
// No Yarn installed, continuing with npm.
args
=
[
'
install
'
,
verbose
&&
'
--verbose
'
,
'
--save-dev
'
,
'
--save-exact
'
,
packageToInstall
,
].
filter
(
function
(
e
)
{
return
e
;
});
var
npmProc
=
spawn
(
'
npm
'
,
args
,
{
stdio
:
'
inherit
'
});
npmProc
.
on
(
'
close
'
,
function
(
code
)
{
callback
(
code
,
'
npm
'
,
args
);
});
});
}
...
...
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