Skip to content

Commit

Permalink
feat: let snyk configure the dir this runs in
Browse files Browse the repository at this point in the history
  • Loading branch information
acunniffe committed Mar 21, 2022
1 parent 393753a commit 0b1ed6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/workflows/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { addDeleteOperation } from "./templates/operations/delete";
import { buildNewResourceSpec } from "./templates/new-resource-spec";
import {
formatResourceVersion,
getSweaterCombWorkingDirectory,
resolveResourcesDirectory,
resolveResourceVersion,
} from "./file-resolvers";
Expand Down Expand Up @@ -66,7 +67,7 @@ export async function promoteVersionAction(
);

const specFilePath = await resolveResourceVersion(
process.cwd(),
getSweaterCombWorkingDirectory(),
resourceName,
"latest",
true,
Expand Down Expand Up @@ -142,7 +143,7 @@ function buildOperationAction(template) {
// TODO: consider how workflows can provided with more sophisticated context
return async (pluralResourceName: string, resourceVersion: string) => {
const specFilePath = await resolveResourceVersion(
process.cwd(),
getSweaterCombWorkingDirectory(),
pluralResourceName,
resourceVersion,
);
Expand Down
8 changes: 6 additions & 2 deletions src/workflows/file-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OpenAPIV3 } from "@useoptic/openapi-utilities";
import { LogUpdatingSpecification } from "./logs";

export async function resolveResourcesDirectory(
workingDirectory: string = process.cwd(),
workingDirectory: string = getSweaterCombWorkingDirectory(),
): Promise<string> {
return new Promise((resolve) => {
findParentDir(workingDirectory, "resources", function (err, dir) {
Expand All @@ -19,7 +19,7 @@ export async function resolveResourcesDirectory(
}

export async function resolveResourceVersion(
workingDirectory: string = process.cwd(),
workingDirectory: string = getSweaterCombWorkingDirectory(),
resourceName: string,
resourceVersion: string = "latest",
silent: boolean = false,
Expand Down Expand Up @@ -93,3 +93,7 @@ export function getSingularAndPluralName(openApi: OpenAPIV3.Document) {
export function titleCase(value: string): string {
return value[0].toUpperCase() + value.slice(1);
}

export function getSweaterCombWorkingDirectory() {
return process.env["SWEATER_COMB_WORKING_DIR"] || process.cwd();
}

0 comments on commit 0b1ed6e

Please sign in to comment.