Skip to content

Commit 13fdf59

Browse files
Dustin FirmanDustin Firman
Dustin Firman
authored and
Dustin Firman
committed
added credential options for custom reops
1 parent f60f6f7 commit 13fdf59

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,26 @@ node-java-maven
7979
}
8080
}
8181

82+
* Add another maven repo
83+
84+
{
85+
"java": {
86+
"repositories": [
87+
{
88+
"id": "maven",
89+
"url": "http://example/repository/maven-public/",
90+
"credentials": {
91+
"username": "user",
92+
"password": "pass"
93+
}
94+
}
95+
],
96+
"dependencies": [
97+
{
98+
"groupId": "org.apache.lucene",
99+
"artifactId": "lucene-core",
100+
"version": "4.9.0"
101+
}
102+
]
103+
}
104+
}

index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,20 @@ module.exports = function(/*options, callback*/) {
442442
function(callback) {
443443
var repository = options.repositories[repositoryIndex];
444444
var url = repository.url + urlPath;
445+
var req_options = { url: url };
446+
if (repository.hasOwnProperty('credentials')) {
447+
var username = repository.credentials.username;
448+
var password = repository.credentials.password;
449+
req_options = {
450+
url: url,
451+
auth: {
452+
user: username,
453+
password: password
454+
}
455+
};
456+
}
445457
debug('downloading ' + url);
446-
var r = request(url);
458+
var r = request(req_options);
447459
r.on('response', function(response) {
448460
if (response.statusCode != 200) {
449461
error = new Error('download failed for ' + url + (reason ? ' (' + reason + ')' : '') + ' [status: ' + response.statusCode + ']');

0 commit comments

Comments
 (0)