Skip to content

Commit

Permalink
refactor: refactor test command
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed Apr 25, 2021
1 parent 3c329ab commit 3b0c02f
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions codeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,36 +467,54 @@ const codeview = new Command<void>()

async function test() {
logInfo("Running tests...");

const testOptions: Array<keyof typeof options> = [
"allowAll",
"allowEnv",
"allowHrtime",
"allowNet",
"allowNone",
"allowPlugin",
"allowRead",
"allowRun",
"allowWrite",
"cachedOnly",
"cert",
"config",
"failFast",
"filter",
"importMap",
"location",
"lock",
"logLevel",
"quiet",
"reload",
"v8Flags",
];

const negatableOptions: Array<keyof typeof options> = [
"check",
"remote",
];

await run({
cmd: [
"deno",
"test",
`--coverage=${options.tmp}/cov`,
"--unstable",
...Object.entries(options)
.filter(([name]) =>
![
"unstable",
"watch",
"tmp",
"port",
"spinner",
"debounce",
"check",
"remote",
"host",
"keep",
"maximize",
]
.includes(name)
...testOptions
.filter((name: keyof typeof options) =>
typeof options[name] !== "undefined"
)
.map(([name, value]) =>
value && value !== true
? `--${paramCase(name)}=${String(value)}`
: `--${paramCase(name)}`
.map((name: keyof typeof options) =>
options[name] === true
? `--${paramCase(name)}`
: `--${paramCase(name)}=${String(options[name])}`
),
...(options.check === false ? ["--no-check"] : []),
...(options.remote === false ? ["--no-remote"] : []),
...negatableOptions
.filter((name: keyof typeof options) => options[name] === false)
.map((name: keyof typeof options) => `--no-${name}`),
...(testFiles ? [testFiles] : []),
],
});
Expand Down

0 comments on commit 3b0c02f

Please sign in to comment.