1 | import * as File from "vinyl";
|
2 |
|
3 | declare namespace Conflicter {
|
4 | /**
|
5 | * Provides options for creating a conflicter.
|
6 | */
|
7 | interface ConflicterOptions {
|
8 | /**
|
9 | * A value indicating whether conflicts shouldn't be checked.
|
10 | */
|
11 | force?: boolean;
|
12 |
|
13 | /**
|
14 | * A value indicating whether the conflicter should stop when the first conflict occurs.
|
15 | */
|
16 | bail?: boolean;
|
17 |
|
18 | /**
|
19 | * A value indicating whether whitespace characters should be ignored when checking for changes.
|
20 | */
|
21 | ignoreWhitespace?: boolean;
|
22 |
|
23 | /**
|
24 | * A value indicating whether identical files should be written to the disk as well.
|
25 | */
|
26 | regenerate?: boolean;
|
27 |
|
28 | /**
|
29 | * A value indicating whether no operations should be executed.
|
30 | */
|
31 | dryRun?: boolean;
|
32 |
|
33 | /**
|
34 | * The path to be used as a reference for relative paths.
|
35 | */
|
36 | cwd?: string;
|
37 | }
|
38 |
|
39 | /**
|
40 | * Represents a file which can be checked for conflicts.
|
41 | */
|
42 | type ConflicterFile = Pick<File, "path" | "contents">;
|
43 |
|
44 | /**
|
45 | * The status of a checked file.
|
46 | */
|
47 | type Status = "skip" | "create" | "force" | "identical";
|
48 |
|
49 | /**
|
50 | * Represents a checked file.
|
51 | */
|
52 | interface CheckedFile extends File {
|
53 | /**
|
54 | * The status of the file.
|
55 | */
|
56 | conflicter: Status;
|
57 | }
|
58 | }
|
59 |
|
60 | declare class Conflicter {
|
61 | /**
|
62 | * A value indicating whether conflicts shouldn't be checked.
|
63 | */
|
64 | force: boolean;
|
65 |
|
66 | /**
|
67 | * Detects conflicts between the actual file located at the `path` and the `contents` passed to the function.
|
68 | *
|
69 | * @param file
|
70 | * The file to check for conflicts.
|
71 | *
|
72 | * @returns
|
73 | * A value indicating whether there is a conflict.
|
74 | */
|
75 | _detectConflict(file: Conflicter.ConflicterFile): boolean;
|
76 |
|
77 | /**
|
78 | * Prints the differences of the specified `file` to the console.
|
79 | *
|
80 | * @param file
|
81 | * The file to print the diff for.
|
82 | */
|
83 | _printDiff(file: Conflicter.ConflicterFile): void;
|
84 |
|
85 | /**
|
86 | * Checks whether the specified `file` conflicts with the file saved on the disk.
|
87 | *
|
88 | * @param file
|
89 | * The file to check for conflicts.
|
90 | */
|
91 | checkForCollision(file: File): Promise<Conflicter.CheckedFile>;
|
92 | }
|
93 |
|
94 | export = Conflicter;
|