mirror of
https://github.com/webfactory/ssh-agent.git
synced 2025-06-28 05:33:45 +00:00
Use different ssh-add command for Windows/!Windows
This commit is contained in:
parent
2bde568a83
commit
7f61bbc4ae
3 changed files with 55 additions and 12 deletions
9
dist/index.js
vendored
9
dist/index.js
vendored
|
@ -120,6 +120,7 @@ const child_process = __webpack_require__(129);
|
|||
const fs = __webpack_require__(747);
|
||||
const os = __webpack_require__(87);
|
||||
const token = __webpack_require__(417).randomBytes(64).toString('hex');
|
||||
const isWindows = (process.env['OS'] == 'Windows_NT');
|
||||
|
||||
try {
|
||||
const privateKey = core.getInput('ssh-private-key');
|
||||
|
@ -132,7 +133,7 @@ try {
|
|||
|
||||
var home;
|
||||
|
||||
if (process.env['OS'] == 'Windows_NT') {
|
||||
if (isWindows) {
|
||||
console.log('Preparing ssh-agent service on Windows');
|
||||
child_process.execSync('sc config ssh-agent start=demand', { stdio: 'inherit' });
|
||||
|
||||
|
@ -191,7 +192,11 @@ try {
|
|||
}
|
||||
|
||||
// Load key into agent
|
||||
child_process.execFileSync('ssh-add', [keyFile], { env: { ...process.env, ...{ 'DISPLAY': 'fake', 'SSH_PASS': token, 'SSH_ASKPASS': 'D:\\a\\ssh-agent\\ssh-agent\\askpass.exe' } } });
|
||||
if (isWindows) {
|
||||
child_process.execFileSync('ssh-add', [keyFile], { env: { ...process.env, ...{ 'DISPLAY': 'fake', 'SSH_PASS': token, 'SSH_ASKPASS': 'D:\\a\\ssh-agent\\ssh-agent\\askpass.exe' } } });
|
||||
} else {
|
||||
child_process.execFileSync('ssh-add', [keyFile], { input: token });
|
||||
}
|
||||
|
||||
output.toString().split(/\r?\n/).forEach(function(key) {
|
||||
let parts = key.match(/^Key has comment '.*\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+?)(?=\.git|\s|\')/);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue