Skip to content

Commit

Permalink
Fix local testing using colors
Browse files Browse the repository at this point in the history
  • Loading branch information
macmv committed Sep 24, 2024
1 parent eb61af4 commit a73b260
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/color.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { stdout } from "supports-color";

var colorEnabled = true;
export const disableColor = () => {
colorEnabled = false;
};

// The value for the `color` parameter to the `/schema/1` endpoints.
export const colorParam = (): string => {
return hasColor() ? "ansi" : "";
};

export const hasColor = (): boolean => {
return stdout !== false && stdout.hasBasic;
return colorEnabled && stdout !== false && stdout.hasBasic;
};
5 changes: 5 additions & 0 deletions test/commands/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const fs = require("fs");
const path = require("path");
const { query: q } = require("faunadb");
const { withOpts, getEndpoint, matchFqlReq } = require("../helpers/utils.js");
const { disableColor } = require("../../src/lib/color");

const main = {
version: 0,
Expand Down Expand Up @@ -40,6 +41,10 @@ const pullfiles = {
const updated = { version: 1 };

describe("fauna schema diff test", () => {
before(() => {
disableColor();
});

it("runs schema diff", async () => {
nock(getEndpoint(), { allowUnmocked: false })
.persist()
Expand Down

0 comments on commit a73b260

Please sign in to comment.