deno.land / std@0.166.0 / _tools / check_assertions.ts

check_assertions.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { createGraph, Module,} from "https://deno.land/x/deno_graph@0.37.1/mod.ts";import { walk } from "../fs/walk.ts";
const ROOT = new URL("../", import.meta.url);const EXTS = [".mjs", ".ts"];const SKIP = [/(test|bench|node\/)/];const BAD_IMPORT = new URL("../testing/asserts.ts", import.meta.url);const EXCEPTION = new URL("../node/assert.ts", import.meta.url);
async function getFilePaths(): Promise<string[]> { const paths: string[] = []; for await (const { path } of walk(ROOT, { exts: EXTS, skip: SKIP })) { paths.push("file://" + path); } return paths;}
function hasBadImports({ dependencies }: Module): boolean { return Object.values(dependencies!) .some(({ code }) => code?.specifier?.includes(BAD_IMPORT.href));}
async function getFilePathsWithBadImports(): Promise<string[]> { const paths = await getFilePaths(); const { modules } = await createGraph(paths); return modules.filter(hasBadImports) .map(({ specifier }: Module) => specifier) .filter((path) => path !== EXCEPTION.href);}
const paths = await getFilePathsWithBadImports();if (paths.length > 0) { console.error( "Non-test code must use `_util/assert.ts` for assertions. Please fix:", ); paths.forEach((path) => console.error("- " + path)); Deno.exit(1);}
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago