This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github: fix the ssh fallback for private github modules
This only impacts github modules installed via github shortcuts, eg npm install project/module When the module is marked as private.
- Loading branch information
Showing
2 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict' | ||
var requireInject = require('require-inject') | ||
var test = require('tap').test | ||
|
||
test('github-shortcut', function (t) { | ||
var cloneUrls = [ | ||
['git://github.com/foo/private.git', 'github shortcuts try git:// first'], | ||
['ssh://git@github.com/foo/private.git', 'github shortcuts try ssh:// urls second'] | ||
] | ||
var npm = requireInject.installGlobally('../../lib/npm.js', { | ||
'child_process': { | ||
'execFile': function (cmd, args, options, cb) { | ||
process.nextTick(function () { | ||
if (args[0] !== 'clone') return cb(null, '', '') | ||
var cloneUrl = cloneUrls.shift() | ||
if (cloneUrl) { | ||
t.is(args[3], cloneUrl[0], cloneUrl[1]) | ||
} else { | ||
t.fail('too many attempts to clone') | ||
} | ||
cb(new Error()) | ||
}) | ||
} | ||
} | ||
}) | ||
|
||
npm.load({loglevel: 'silent'}, function () { | ||
npm.commands.install(['foo/private'], function (er, result) { | ||
t.end() | ||
}) | ||
}) | ||
}) |