Skip to content

armgit / clipy

Public Imported from GitHub
0

The AI-native screen recorder. Record your screen and talk; the people you share it with and your AI agents both get it.

1.5 KB
Raw Blame
#!/usr/bin/env node
// The generated Gemini command must not depend on the checkout's line endings.
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import test from "node:test";
import { normalizeNewlines, render } from "./gen-gemini-watch.mjs";

const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const skill = normalizeNewlines(readFileSync(join(root, "plugins/watch/skills/watch/SKILL.md"), "utf8"));
const toCrlf = (text) => normalizeNewlines(text).replaceAll("\n", "\r\n");

test("normalizeNewlines turns CRLF into LF and leaves LF alone", () => {
  assert.equal(normalizeNewlines("a\r\nb\nc\r\n"), "a\nb\nc\n");
});

test("a CRLF SKILL.md renders the same LF command as an LF one", () => {
  const fromLf = render(skill);
  const fromCrlf = render(toCrlf(skill));
  assert.equal(fromCrlf, fromLf);
  assert.ok(!fromCrlf.includes("\r"), "the generated command has no carriage returns");
});

test("a CRLF copy of the generated command compares equal after normalizing", () => {
  const generated = render(skill);
  assert.equal(normalizeNewlines(toCrlf(generated)), generated);
});

test("--check passes for the checked-in command, whatever this checkout's line endings", () => {
  const out = execFileSync(process.execPath, [join(root, "scripts/gen-gemini-watch.mjs"), "--check"], { encoding: "utf8" });
  assert.match(out, /in sync/);
});