Skip to content

Commit c57116a

Browse files
committed
fix(mock): Fixed mocking 2nd level dependency
fixes #19
1 parent a713009 commit c57116a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/get-readme.js

+18-12
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,26 @@ var utils = require('./utils');
66

77
// working around github-url-to-object used inside get-package-readme
88
// that cannot handle www.github.com urls
9+
// this does NOT work on npm2 where it cannot find github-url-to-object
10+
// due to multi level folder
911
/* eslint no-undef:0 */
10-
require = require('really-need');
11-
require('github-url-to-object', {
12-
post: function () {
13-
return function gh(url) {
14-
log('parsing github url %s ourselves', url);
15-
var parsed = parseGithubRepoUrl(url);
16-
return {
17-
user: parsed[0],
18-
repo: parsed[1]
12+
try {
13+
require = require('really-need');
14+
require('github-url-to-object', {
15+
post: function () {
16+
return function gh(url) {
17+
log('parsing github url %s ourselves', url);
18+
var parsed = parseGithubRepoUrl(url);
19+
return {
20+
user: parsed[0],
21+
repo: parsed[1]
22+
};
1923
};
20-
};
21-
}
22-
});
24+
}
25+
});
26+
} catch (err) {
27+
// ignore
28+
}
2329

2430
var Promise = require('bluebird');
2531
var getReadmeFile = Promise.promisify(require('get-package-readme'));

0 commit comments

Comments
 (0)