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
843e03c5
Commit
843e03c5
authored
8 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
Refactor argument checks
parent
8ad6845d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/index.js
+28
-22
28 additions, 22 deletions
src/index.js
with
28 additions
and
22 deletions
src/index.js
+
28
−
22
View file @
843e03c5
...
...
@@ -5,42 +5,48 @@ const config = require('./config');
const
github
=
require
(
'
./github
'
);
const
npm
=
require
(
'
./npm
'
);
const
token
=
process
.
env
.
RENOVATE_TOKEN
;
// token must be defined
if
(
typeof
token
===
'
undefined
'
)
{
console
.
error
(
'
Error: Environment variable RENOVATE_TOKEN must be defined
'
);
process
.
exit
(
1
);
}
if
(
process
.
argv
.
length
<
3
||
process
.
argv
.
length
>
4
)
{
console
.
error
(
'
Error: You must specify the GitHub repository and optionally path.
'
);
console
.
log
(
'
Example: node src singapore/renovate
'
);
console
.
log
(
'
Example: node src foo/bar baz/package.json
'
);
process
.
exit
(
1
);
}
npm
.
init
(
config
.
verbose
);
// Process
command line
arguments
// Process arguments
const
repoName
=
process
.
argv
[
2
];
const
userName
=
repoName
.
split
(
'
/
'
)[
0
];
const
packageFile
=
process
.
argv
[
3
]
||
'
package.json
'
;;
npm
.
init
(
config
.
verbose
);
const
packageFile
=
process
.
argv
[
3
]
||
'
package.json
'
;
const
token
=
process
.
env
.
RENOVATE_TOKEN
;
let
basePackageJson
;
validateArguments
()
;
github
.
init
(
token
,
repoName
,
config
.
baseBranch
,
config
.
verbose
)
initializeGitHub
(
)
.
then
(
getPackageFileContents
)
.
then
(
g
et
All
Upgrades
)
.
then
(
d
et
ermine
Upgrades
)
.
then
(
processUpgradesSequentially
)
.
catch
(
err
=>
{
console
.
log
(
'
updateDependency error:
'
+
err
);
});
function
validateArguments
()
{
// token must be defined
if
(
typeof
token
===
'
undefined
'
)
{
console
.
error
(
'
Error: Environment variable RENOVATE_TOKEN must be defined
'
);
process
.
exit
(
1
);
}
// Check arguments
if
(
process
.
argv
.
length
<
3
||
process
.
argv
.
length
>
4
)
{
console
.
error
(
'
Error: You must specify the GitHub repository and optionally path.
'
);
console
.
log
(
'
Example: node src singapore/renovate
'
);
console
.
log
(
'
Example: node src foo/bar baz/package.json
'
);
process
.
exit
(
1
);
}
}
function
initializeGitHub
()
{
return
github
.
init
(
token
,
repoName
,
config
.
baseBranch
,
config
.
verbose
);
}
function
getPackageFileContents
()
{
return
github
.
getFileContents
(
packageFile
);
}
function
g
et
All
Upgrades
(
packageFileContents
)
{
function
d
et
ermine
Upgrades
(
packageFileContents
)
{
return
npm
.
getAllDependencyUpgrades
(
packageFileContents
);
}
...
...
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