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
1896512b
Commit
1896512b
authored
8 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
Refactor promise chains
parent
7723e860
No related branches found
Branches containing commit
Tags
34.150.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/github.js
+9
-7
9 additions, 7 deletions
src/github.js
src/index.js
+14
-9
14 additions, 9 deletions
src/index.js
with
23 additions
and
16 deletions
src/github.js
+
9
−
7
View file @
1896512b
...
@@ -56,14 +56,9 @@ module.exports = {
...
@@ -56,14 +56,9 @@ module.exports = {
console
.
error
(
'
Error checking if PR already existed
'
);
console
.
error
(
'
Error checking if PR already existed
'
);
});
});
},
},
getFile
:
function
(
filePath
,
branchName
)
{
getFile
:
getFile
,
branchName
=
branchName
||
config
.
baseBranch
;
return
ghGot
(
`repos/
${
config
.
repoName
}
/contents/
${
filePath
}
?ref=
${
branchName
}
`
,
{
token
:
config
.
token
,
});
},
getFileContents
:
function
(
filePath
,
branchName
)
{
getFileContents
:
function
(
filePath
,
branchName
)
{
return
this
.
getFile
(
filePath
,
branchName
).
then
(
res
=>
{
return
getFile
(
filePath
,
branchName
).
then
(
res
=>
{
return
JSON
.
parse
(
new
Buffer
(
res
.
body
.
content
,
'
base64
'
).
toString
());
return
JSON
.
parse
(
new
Buffer
(
res
.
body
.
content
,
'
base64
'
).
toString
());
});
});
},
},
...
@@ -98,3 +93,10 @@ module.exports = {
...
@@ -98,3 +93,10 @@ module.exports = {
});
});
},
},
};
};
function
getFile
(
filePath
,
branchName
)
{
branchName
=
branchName
||
config
.
baseBranch
;
return
ghGot
(
`repos/
${
config
.
repoName
}
/contents/
${
filePath
}
?ref=
${
branchName
}
`
,
{
token
:
config
.
token
,
});
}
This diff is collapsed.
Click to expand it.
src/index.js
+
14
−
9
View file @
1896512b
...
@@ -22,18 +22,25 @@ if (process.argv.length < 3 || process.argv.length > 4) {
...
@@ -22,18 +22,25 @@ if (process.argv.length < 3 || process.argv.length > 4) {
// Process command line arguments
// Process command line arguments
const
repoName
=
process
.
argv
[
2
];
const
repoName
=
process
.
argv
[
2
];
const
userName
=
repoName
.
split
(
'
/
'
)[
0
];
const
userName
=
repoName
.
split
(
'
/
'
)[
0
];
const
packageFile
=
process
.
argv
[
3
]
||
'
package.json
'
;
const
packageFile
=
process
.
argv
[
3
]
||
'
package.json
'
;
;
npm
.
init
(
config
.
verbose
);
npm
.
init
(
config
.
verbose
);
let
basePackageJson
;
let
basePackageJson
;
github
.
init
(
token
,
repoName
,
config
.
baseBranch
,
config
.
verbose
).
then
(()
=>
{
github
.
init
(
token
,
repoName
,
config
.
baseBranch
,
config
.
verbose
)
// Get the base package.json
.
then
(
getPackageFile
)
return
github
.
getFileContents
(
packageFile
);
})
.
then
(
npm
.
getAllDependencyUpgrades
)
.
then
(
npm
.
getAllDependencyUpgrades
)
.
then
((
upgrades
)
=>
{
.
then
(
processUpgradesSequentially
)
.
catch
(
err
=>
{
console
.
log
(
'
updateDependency error:
'
+
err
);
});
function
getPackageFile
()
{
return
github
.
getFileContents
(
packageFile
);
}
function
processUpgradesSequentially
(
upgrades
)
{
if
(
config
.
verbose
)
{
if
(
config
.
verbose
)
{
console
.
log
(
'
All upgrades:
'
+
JSON
.
stringify
(
upgrades
));
console
.
log
(
'
All upgrades:
'
+
JSON
.
stringify
(
upgrades
));
}
}
...
@@ -45,9 +52,7 @@ github.init(token, repoName, config.baseBranch, config.verbose).then(() => {
...
@@ -45,9 +52,7 @@ github.init(token, repoName, config.baseBranch, config.verbose).then(() => {
return
updateDependency
(
upgrade
.
depType
,
upgrade
.
depName
,
upgrade
.
currentVersion
,
upgrade
.
nextVersion
);
return
updateDependency
(
upgrade
.
depType
,
upgrade
.
depName
,
upgrade
.
currentVersion
,
upgrade
.
nextVersion
);
});
});
},
Promise
.
resolve
());
},
Promise
.
resolve
());
}).
catch
(
err
=>
{
}
console
.
log
(
'
updateDependency error:
'
+
err
);
});
function
updateDependency
(
depType
,
depName
,
currentVersion
,
nextVersion
)
{
function
updateDependency
(
depType
,
depName
,
currentVersion
,
nextVersion
)
{
const
nextVersionMajor
=
semver
.
major
(
nextVersion
);
const
nextVersionMajor
=
semver
.
major
(
nextVersion
);
...
...
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