feat: support secret environment variables in CLI (#3815)

This commit is contained in:
James George
2024-02-08 22:08:18 +05:30
committed by GitHub
parent 00862eb192
commit 5bcc38e36b
30 changed files with 791 additions and 145 deletions

View File

@@ -3,13 +3,13 @@ import { resolve } from "path";
import { ExecResponse } from "./types";
export const runCLI = (args: string): Promise<ExecResponse> =>
export const runCLI = (args: string, options = {}): Promise<ExecResponse> =>
{
const CLI_PATH = resolve(__dirname, "../../bin/hopp");
const command = `node ${CLI_PATH} ${args}`
return new Promise((resolve) =>
exec(command, (error, stdout, stderr) => resolve({ error, stdout, stderr }))
exec(command, options, (error, stdout, stderr) => resolve({ error, stdout, stderr }))
);
}
@@ -25,7 +25,12 @@ export const getErrorCode = (out: string) => {
return ansiTrimmedStr.split(" ")[0];
};
export const getTestJsonFilePath = (file: string) => {
const filePath = resolve(__dirname, `../../src/__tests__/samples/${file}`);
export const getTestJsonFilePath = (file: string, kind: "collection" | "environment") => {
const kindDir = {
collection: "collections",
environment: "environments",
}[kind];
const filePath = resolve(__dirname, `../../src/__tests__/samples/${kindDir}/${file}`);
return filePath;
};