forked from denoland/dnt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnpm_ignore.ts
More file actions
71 lines (67 loc) · 2.23 KB
/
Copy pathnpm_ignore.ts
File metadata and controls
71 lines (67 loc) · 2.23 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2018-2024 the Deno authors. MIT license.
import type { OutputFile } from "../transform.ts";
import type { SourceMapOptions } from "./compiler.ts";
export function getNpmIgnoreText(options: {
sourceMap?: SourceMapOptions;
inlineSources?: boolean;
testFiles: OutputFile[];
declaration: "separate" | "inline" | false;
declarationMap: boolean | undefined;
includeScriptModule: boolean | undefined;
includeEsModule: boolean | undefined;
}) {
// Try to make as little of this conditional in case a user edits settings
// to exclude something, but then the output directory still has that file
const lines = [];
if (!isUsingSourceMaps() || options.inlineSources) {
lines.push("/src/");
}
for (const fileName of getTestFileNames()) {
lines.push(fileName);
}
lines.push("yarn.lock", "pnpm-lock.yaml");
return Array.from(lines).join("\n") + "\n";
function* getTestFileNames() {
for (const file of options.testFiles) {
const filePath = file.filePath.replace(/\.ts$/i, ".js");
const dtsFilePath = file.filePath.replace(/\.ts$/i, ".d.ts");
if (options.includeEsModule) {
const esmFilePath = `/esm/${filePath}`;
yield esmFilePath;
if (options.sourceMap === true) {
yield `${esmFilePath}.map`;
}
if (options.declaration === "inline") {
yield `/esm/${dtsFilePath}`;
if (options.declarationMap) {
yield `/esm/${dtsFilePath}.map`;
}
}
}
if (options.includeScriptModule) {
const scriptFilePath = `/script/${filePath}`;
yield scriptFilePath;
if (options.sourceMap === true) {
yield `${scriptFilePath}.map`;
}
if (options.declaration === "inline") {
yield `/script/${dtsFilePath}`;
if (options.declarationMap) {
yield `/script/${dtsFilePath}.map`;
}
}
}
if (options.declaration === "separate") {
yield `/types/${dtsFilePath}`;
if (options.declarationMap) {
yield `/types/${dtsFilePath}.map`;
}
}
}
yield "/test_runner.cjs";
}
function isUsingSourceMaps() {
return options?.sourceMap === "inline" ||
options?.sourceMap === true;
}
}