Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
GitHub Mirror
Renovate Bot
renovate
Commits
16aff741
Unverified
Commit
16aff741
authored
3 years ago
by
Derek
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(yarn): ignore yarn-path if binary does not exist (#12322)
Co-authored-by:
Rhys Arkins
<
rhys@arkins.net
>
parent
48c5a3c5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/manager/npm/post-update/yarn.spec.ts
+34
-0
34 additions, 0 deletions
lib/manager/npm/post-update/yarn.spec.ts
lib/manager/npm/post-update/yarn.ts
+10
-1
10 additions, 1 deletion
lib/manager/npm/post-update/yarn.ts
with
44 additions
and
1 deletion
lib/manager/npm/post-update/yarn.spec.ts
+
34
−
0
View file @
16aff741
...
...
@@ -223,6 +223,12 @@ describe('manager/npm/post-update/yarn', () => {
describe
(
'
checkYarnrc()
'
,
()
=>
{
it
(
'
returns offline mirror and yarn path
'
,
async
()
=>
{
fs
.
exists
.
mockImplementation
((
path
)
=>
{
if
(
path
===
'
./.yarn/cli.js
'
)
{
return
new
Promise
<
boolean
>
((
resolve
)
=>
resolve
(
true
));
}
return
new
Promise
<
boolean
>
((
resolve
)
=>
resolve
(
false
));
});
fs
.
readFile
.
mockImplementation
((
filename
,
encoding
)
=>
{
if
(
filename
.
endsWith
(
'
.yarnrc
'
))
{
return
new
Promise
<
string
>
((
resolve
)
=>
...
...
@@ -238,6 +244,12 @@ describe('manager/npm/post-update/yarn', () => {
});
it
(
'
returns no offline mirror and unquoted yarn path
'
,
async
()
=>
{
fs
.
exists
.
mockImplementation
((
path
)
=>
{
if
(
path
===
'
./.yarn/cli.js
'
)
{
return
new
Promise
<
boolean
>
((
resolve
)
=>
resolve
(
true
));
}
return
new
Promise
<
boolean
>
((
resolve
)
=>
resolve
(
false
));
});
fs
.
readFile
.
mockImplementation
((
filename
,
encoding
)
=>
{
if
(
filename
.
endsWith
(
'
.yarnrc
'
))
{
return
new
Promise
<
string
>
((
resolve
)
=>
...
...
@@ -249,5 +261,27 @@ describe('manager/npm/post-update/yarn', () => {
// FIXME: explicit assert condition
expect
(
await
_yarnHelper
.
checkYarnrc
(
'
/tmp/renovate
'
)).
toMatchSnapshot
();
});
it
(
'
returns offline mirror and no yarn path for non-existant yarn-path binary
'
,
async
()
=>
{
let
yarnrcContents
=
'
yarn-path ./.yarn/cli.js
\n
'
;
fs
.
writeFile
.
mockImplementation
((
filename
,
fileContents
)
=>
{
if
(
filename
.
endsWith
(
'
.yarnrc
'
))
{
yarnrcContents
=
fileContents
;
}
return
new
Promise
<
void
>
((
resolve
)
=>
resolve
());
});
fs
.
readFile
.
mockImplementation
((
filename
,
encoding
)
=>
{
if
(
filename
.
endsWith
(
'
.yarnrc
'
))
{
return
new
Promise
<
string
>
((
resolve
)
=>
resolve
(
yarnrcContents
));
}
return
new
Promise
<
string
>
((
resolve
)
=>
resolve
(
''
));
});
const
{
offlineMirror
,
yarnPath
}
=
await
_yarnHelper
.
checkYarnrc
(
'
/tmp/renovate
'
);
expect
(
offlineMirror
).
toBeFalse
();
expect
(
yarnPath
).
toBeNull
();
expect
(
yarnrcContents
).
not
.
toContain
(
'
yarn-path
'
);
});
});
});
This diff is collapsed.
Click to expand it.
lib/manager/npm/post-update/yarn.ts
+
10
−
1
View file @
16aff741
...
...
@@ -11,7 +11,7 @@ import { id as npmId } from '../../../datasource/npm';
import
{
logger
}
from
'
../../../logger
'
;
import
{
ExternalHostError
}
from
'
../../../types/errors/external-host-error
'
;
import
{
ExecOptions
,
exec
}
from
'
../../../util/exec
'
;
import
{
readFile
,
remove
}
from
'
../../../util/fs
'
;
import
{
exists
,
readFile
,
remove
,
writeFile
}
from
'
../../../util/fs
'
;
import
{
regEx
}
from
'
../../../util/regex
'
;
import
type
{
PostUpdateConfig
,
Upgrade
}
from
'
../../types
'
;
import
{
getNodeConstraint
}
from
'
./node-version
'
;
...
...
@@ -35,6 +35,15 @@ export async function checkYarnrc(
if
(
pathLine
)
{
yarnPath
=
pathLine
.
replace
(
regEx
(
/^yarn-path
\s
+"
?(
.+
?)
"
?
$/
),
'
$1
'
);
}
const
yarnBinaryExists
=
await
exists
(
yarnPath
);
if
(
!
yarnBinaryExists
)
{
const
scrubbedYarnrc
=
yarnrc
.
replace
(
regEx
(
/^yarn-path
\s
+"
?
.+
?
"
?
$/gm
),
''
);
await
writeFile
(
`
${
cwd
}
/.yarnrc`
,
scrubbedYarnrc
);
yarnPath
=
null
;
}
}
}
catch
(
err
)
/* istanbul ignore next */
{
// not found
...
...
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