Skip to content

Commit

Permalink
Merge pull request #13 from crazy-max/master
Browse files Browse the repository at this point in the history
Take the password from stdin
  • Loading branch information
crazy-max committed Sep 24, 2020
2 parents 53f337d + b7800fe commit 0f9fb80
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 38 deletions.
30 changes: 0 additions & 30 deletions CHANGELOG.md

This file was deleted.

9 changes: 5 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function logout(registry: string): Promise<void> {
}

export async function loginStandard(registry: string, username: string, password: string): Promise<void> {
let loginArgs: Array<string> = ['login', '--password', password];
let loginArgs: Array<string> = ['login', '--password-stdin'];
if (username) {
loginArgs.push('--username', username);
}
Expand All @@ -30,7 +30,7 @@ export async function loginStandard(registry: string, username: string, password
} else {
core.info(`🔑 Logging into DockerHub...`);
}
await execm.exec('docker', loginArgs, true).then(res => {
await execm.exec('docker', loginArgs, true, password).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
Expand Down
10 changes: 8 additions & 2 deletions src/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ export interface ExecResult {
stderr: string;
}

export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => {
export const exec = async (
command: string,
args: string[] = [],
silent: boolean,
stdin?: string
): Promise<ExecResult> => {
let stdout: string = '';
let stderr: string = '';

const options: ExecOptions = {
silent: silent,
ignoreReturnCode: true
ignoreReturnCode: true,
input: Buffer.from(stdin || '')
};
options.listeners = {
stdout: (data: Buffer) => {
Expand Down

0 comments on commit 0f9fb80

Please sign in to comment.