testTokensNeverStartWithADash

tcmts.cli.sync.test.testTokensNeverStartWithADash · #lu63ugyr · function

Tokens never start with -: given on a command line (--token <token>), one would be read as a flag. (One in 64 random ones would: 2000 of them have one, all but surely.)

import { newToken } from "#codebase/tcmts/cli/sync";
import assert from "node:assert/strict";

export const testTokensNeverStartWithADash = () => {
  for (let i = 0; i < 2000; i++) {
    const t = newToken();
    assert.ok(!t.startsWith("-"), t);
    assert.match(t, /^[\w-]{24}$/);
  }
}

uses