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
caa2c413
Commit
caa2c413
authored
4 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
refactor: simplify fetching logic
parent
7d54d7bc
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/workers/repository/process/fetch.spec.ts
+1
-1
1 addition, 1 deletion
lib/workers/repository/process/fetch.spec.ts
lib/workers/repository/process/fetch.ts
+4
-16
4 additions, 16 deletions
lib/workers/repository/process/fetch.ts
with
5 additions
and
17 deletions
lib/workers/repository/process/fetch.spec.ts
+
1
−
1
View file @
caa2c413
...
@@ -84,7 +84,7 @@ describe('workers/repository/process/fetch', () => {
...
@@ -84,7 +84,7 @@ describe('workers/repository/process/fetch', () => {
};
};
// TODO: fix types
// TODO: fix types
npm
.
getPackageUpdates
=
jest
.
fn
((
_
)
=>
[
'
a
'
,
'
b
'
]
as
never
);
npm
.
getPackageUpdates
=
jest
.
fn
((
_
)
=>
[
'
a
'
,
'
b
'
]
as
never
);
lookupUpdates
.
mockResolvedValue
([
'
a
'
,
'
b
'
]
as
never
);
lookupUpdates
.
mockResolvedValue
(
{
updates
:
[
'
a
'
,
'
b
'
]
}
as
never
);
await
fetchUpdates
(
config
,
packageFiles
);
await
fetchUpdates
(
config
,
packageFiles
);
expect
(
packageFiles
).
toMatchSnapshot
();
expect
(
packageFiles
).
toMatchSnapshot
();
expect
(
packageFiles
.
npm
[
0
].
deps
[
0
].
skipReason
).
toBeUndefined
();
expect
(
packageFiles
.
npm
[
0
].
deps
[
0
].
skipReason
).
toBeUndefined
();
...
...
This diff is collapsed.
Click to expand it.
lib/workers/repository/process/fetch.ts
+
4
−
16
View file @
caa2c413
import
is
from
'
@sindresorhus/is
'
;
import
pAll
from
'
p-all
'
;
import
pAll
from
'
p-all
'
;
import
{
logger
}
from
'
../../../logger
'
;
import
{
logger
}
from
'
../../../logger
'
;
import
{
getPackageUpdates
}
from
'
../../../manager
'
;
import
{
getPackageUpdates
}
from
'
../../../manager
'
;
...
@@ -9,12 +8,8 @@ import {
...
@@ -9,12 +8,8 @@ import {
ManagerConfig
,
ManagerConfig
,
}
from
'
../../../config
'
;
}
from
'
../../../config
'
;
import
{
applyPackageRules
}
from
'
../../../util/package-rules
'
;
import
{
applyPackageRules
}
from
'
../../../util/package-rules
'
;
import
{
lookupUpdates
,
LookupUpdateConfig
,
UpdateResult
}
from
'
./lookup
'
;
import
{
lookupUpdates
,
LookupUpdateConfig
}
from
'
./lookup
'
;
import
{
import
{
PackageFile
,
PackageDependency
}
from
'
../../../manager/common
'
;
PackageFile
,
PackageDependency
,
PackageUpdateResult
,
}
from
'
../../../manager/common
'
;
import
{
SkipReason
}
from
'
../../../types
'
;
import
{
SkipReason
}
from
'
../../../types
'
;
import
{
clone
}
from
'
../../../util/clone
'
;
import
{
clone
}
from
'
../../../util/clone
'
;
...
@@ -48,17 +43,10 @@ async function fetchDepUpdates(
...
@@ -48,17 +43,10 @@ async function fetchDepUpdates(
logger
.
debug
({
dependency
:
dep
.
depName
},
'
Dependency is disabled
'
);
logger
.
debug
({
dependency
:
dep
.
depName
},
'
Dependency is disabled
'
);
dep
.
skipReason
=
SkipReason
.
Disabled
;
dep
.
skipReason
=
SkipReason
.
Disabled
;
}
else
{
}
else
{
let
lookupResults
:
UpdateResult
|
PackageUpdateResult
[];
if
(
depConfig
.
datasource
)
{
if
(
depConfig
.
datasource
)
{
lookupResults
=
await
lookupUpdates
(
depConfig
as
LookupUpdateConfig
);
Object
.
assign
(
dep
,
await
lookupUpdates
(
depConfig
as
LookupUpdateConfig
));
}
else
{
lookupResults
=
await
getPackageUpdates
(
manager
,
depConfig
);
}
// istanbul ignore else
if
(
is
.
array
(
lookupResults
))
{
dep
.
updates
=
lookupResults
;
}
else
{
}
else
{
Object
.
assign
(
dep
,
lookupResults
);
dep
.
updates
=
await
getPackageUpdates
(
manager
,
depConfig
);
}
}
// istanbul ignore if
// istanbul ignore if
if
(
dep
.
updates
.
length
)
{
if
(
dep
.
updates
.
length
)
{
...
...
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