-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
26 lines (20 loc) · 685 Bytes
/
index.ts
File metadata and controls
26 lines (20 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as path from 'path';
import { promisify } from 'util';
const exec = promisify(require('child_process').exec);
export interface ICredential { username: string, password: string }
const appRoot: string = path.resolve(__dirname);
function buildCredential(credStr: string): ICredential {
const [username, password] = credStr.split(':');
return {
username,
password,
};
}
export function getCredential(target: string, pythonLancher: string = 'python'): Promise<ICredential> {
const script = `${pythonLancher} ${appRoot}\\wincred.py ${target}`;
return exec(script)
.then(result => result.stdout.trim())
.then(buildCredential);
}
export default getCredential;