Skip to content

Commit

Permalink
fix(mock): Fixed mocking 2nd level dependency
Browse files Browse the repository at this point in the history
fixes #19
  • Loading branch information
bahmutov committed Dec 1, 2015
1 parent a713009 commit c57116a
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/get-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@ var utils = require('./utils');

// working around github-url-to-object used inside get-package-readme
// that cannot handle www.github.com urls
// this does NOT work on npm2 where it cannot find github-url-to-object
// due to multi level folder
/* eslint no-undef:0 */
require = require('really-need');
require('github-url-to-object', {
post: function () {
return function gh(url) {
log('parsing github url %s ourselves', url);
var parsed = parseGithubRepoUrl(url);
return {
user: parsed[0],
repo: parsed[1]
try {
require = require('really-need');
require('github-url-to-object', {
post: function () {
return function gh(url) {
log('parsing github url %s ourselves', url);
var parsed = parseGithubRepoUrl(url);
return {
user: parsed[0],
repo: parsed[1]
};
};
};
}
});
}
});
} catch (err) {
// ignore
}

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

0 comments on commit c57116a

Please sign in to comment.