Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
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
No related tags found
No related merge requests found
Changes
2
Show 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 = {
console
.
error
(
'
Error checking if PR already existed
'
);
});
},
getFile
:
function
(
filePath
,
branchName
)
{
branchName
=
branchName
||
config
.
baseBranch
;
return
ghGot
(
`repos/
${
config
.
repoName
}
/contents/
${
filePath
}
?ref=
${
branchName
}
`
,
{
token
:
config
.
token
,
});
},
getFile
:
getFile
,
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
());
});
},
...
...
@@ -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) {
// Process command line arguments
const
repoName
=
process
.
argv
[
2
];
const
userName
=
repoName
.
split
(
'
/
'
)[
0
];
const
packageFile
=
process
.
argv
[
3
]
||
'
package.json
'
;
const
packageFile
=
process
.
argv
[
3
]
||
'
package.json
'
;
;
npm
.
init
(
config
.
verbose
);
let
basePackageJson
;
github
.
init
(
token
,
repoName
,
config
.
baseBranch
,
config
.
verbose
).
then
(()
=>
{
// Get the base package.json
return
github
.
getFileContents
(
packageFile
);
})
github
.
init
(
token
,
repoName
,
config
.
baseBranch
,
config
.
verbose
)
.
then
(
getPackageFile
)
.
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
)
{
console
.
log
(
'
All upgrades:
'
+
JSON
.
stringify
(
upgrades
));
}
...
...
@@ -45,9 +52,7 @@ github.init(token, repoName, config.baseBranch, config.verbose).then(() => {
return
updateDependency
(
upgrade
.
depType
,
upgrade
.
depName
,
upgrade
.
currentVersion
,
upgrade
.
nextVersion
);
});
},
Promise
.
resolve
());
}).
catch
(
err
=>
{
console
.
log
(
'
updateDependency error:
'
+
err
);
});
}
function
updateDependency
(
depType
,
depName
,
currentVersion
,
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