Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit abcdb4a

Browse files
Attempting to use LoginManager to run octorun
1 parent 76e34d4 commit abcdb4a

File tree

8 files changed

+25
-19
lines changed

8 files changed

+25
-19
lines changed

octorun/bin/octorun

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
22

3-
console.log("node:", process.argv[0]);
3+
process.stdout.write("node:", process.argv[0]);
44

55
require('../src/bin/app.js');

octorun/src/bin/app-login.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ commander
99

1010
if (commander.twoFactor) {
1111
authentication.handleTwoFactorAuthentication(function (token) {
12-
console.log(token);
12+
process.stdout.write(token);
1313
process.exit();
1414
}, function (err) {
15-
console.log(err);
15+
process.stdout.write(err);
1616
process.exit();
1717
});
1818
}
1919
else {
2020
authentication.handleBasicAuthentication(function (token) {
21-
console.log(token);
21+
process.stdout.write(token);
2222
process.exit();
2323
}, function () {
24-
console.log("Must specify two-factor authentication OTP code.");
24+
process.stdout.write("Must specify two-factor authentication OTP code.");
2525
process.exit();
2626
}, function (err) {
27-
console.log(err);
27+
process.stdout.write(err);
2828
process.exit();
2929
});
3030
}

octorun/src/bin/app-organizations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ commander
99
var apiWrapper = new ApiWrapper();
1010
apiWrapper.getOrgs(function (error, result) {
1111
if (error) {
12-
console.log(error);
12+
process.stdout.write(error);
1313
process.exit(-1);
1414
}
1515
else {
16-
console.log(result);
16+
process.stdout.write(result);
1717
process.exit();
1818
}
1919
});

octorun/src/bin/app-publish.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ commander
1212

1313
if(!commander.repository)
1414
{
15-
console.log("repository required");
15+
process.stdout.write("repository required");
1616
commander.help();
1717
process.exit(-1);
1818
return;
@@ -28,11 +28,11 @@ var apiWrapper = new ApiWrapper();
2828
apiWrapper.publish(commander.repository, commander.description, private, commander.organization,
2929
function (error, result) {
3030
if (error) {
31-
console.log(error);
31+
process.stdout.write(error);
3232
process.exit(-1);
3333
}
3434
else {
35-
console.log(result);
35+
process.stdout.write(result);
3636
process.exit();
3737
}
3838
});

octorun/src/bin/app-usage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var options = {
2121
};
2222

2323
var req = https.request(options, function (res) {
24-
console.log('statusCode:', res.statusCode);
24+
process.stdout.write('statusCode:', res.statusCode);
2525

2626
res.on('data', function (d) {
2727
process.stdout.write(d);

octorun/src/bin/app-validate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ var apiWrapper = new ApiWrapper();
1010

1111
apiWrapper.verifyUser(function (error, result) {
1212
if (error) {
13-
console.log(error);
13+
process.stdout.write(error);
1414
process.exit(-1);
1515
}
1616
else {
17-
console.log(result);
17+
process.stdout.write(result);
1818
process.exit();
1919
}
2020
});

octorun/src/configuration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require("dotenv").config();
1+
require("dotenv").config({silent: true});
22

33
var clientId = process.env.OCTOKIT_CLIENT_ID;
44
var clientSecret = process.env.OCTOKIT_CLIENT_SECRET;

src/GitHub.Api/Authentication/LoginManager.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private async Task<ApplicationAuthorization> TryLogin(
259259
string password
260260
)
261261
{
262-
logger.Info("Login Username:{0} {1}", username, octorunScript);
262+
logger.Info("Login Username:{0} Script:{1}", username, octorunScript);
263263

264264
ApplicationAuthorization auth = null;
265265
var loginTask = new SimpleListProcessTask(taskManager.Token, nodeJsExecutablePath, $"{octorunScript} login");
@@ -270,11 +270,17 @@ string password
270270
proc.StandardInput.WriteLine(password);
271271
proc.StandardInput.Close();
272272
};
273-
var ret = await loginTask.StartAwait();
274273

275-
foreach (var result in ret)
274+
loginTask.OnEndProcess += proc => {
275+
logger.Trace("Exit Code: ", proc.Process.ExitCode);
276+
};
277+
278+
var ret = (await loginTask.StartAwait()).ToArray();
279+
280+
for (var index = 0; index < ret.Length; index++)
276281
{
277-
logger.Trace(result);
282+
var result = ret[index];
283+
logger.Trace("line {0}: {1}", index, result);
278284
}
279285

280286
throw new Exception("Authentication failed");

0 commit comments

Comments
 (0)