UNPKG

2.1 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/// <reference types="node" />
9import { Path, PathFragment } from '@angular-devkit/core';
10import { Action } from './action';
11export declare enum MergeStrategy {
12 AllowOverwriteConflict = 2,
13 AllowCreationConflict = 4,
14 AllowDeleteConflict = 8,
15 Default = 0,
16 Error = 1,
17 ContentOnly = 2,
18 Overwrite = 14
19}
20export declare const FileVisitorCancelToken: symbol;
21export declare type FileVisitor = FilePredicate<void>;
22export interface FileEntry {
23 readonly path: Path;
24 readonly content: Buffer;
25}
26export interface DirEntry {
27 readonly parent: DirEntry | null;
28 readonly path: Path;
29 readonly subdirs: PathFragment[];
30 readonly subfiles: PathFragment[];
31 dir(name: PathFragment): DirEntry;
32 file(name: PathFragment): FileEntry | null;
33 visit(visitor: FileVisitor): void;
34}
35export interface FilePredicate<T> {
36 (path: Path, entry?: Readonly<FileEntry> | null): T;
37}
38export declare const TreeSymbol: symbol;
39export interface Tree {
40 branch(): Tree;
41 merge(other: Tree, strategy?: MergeStrategy): void;
42 readonly root: DirEntry;
43 read(path: string): Buffer | null;
44 exists(path: string): boolean;
45 get(path: string): FileEntry | null;
46 getDir(path: string): DirEntry;
47 visit(visitor: FileVisitor): void;
48 overwrite(path: string, content: Buffer | string): void;
49 beginUpdate(path: string): UpdateRecorder;
50 commitUpdate(record: UpdateRecorder): void;
51 create(path: string, content: Buffer | string): void;
52 delete(path: string): void;
53 rename(from: string, to: string): void;
54 apply(action: Action, strategy?: MergeStrategy): void;
55 readonly actions: Action[];
56}
57export interface UpdateRecorder {
58 insertLeft(index: number, content: Buffer | string): UpdateRecorder;
59 insertRight(index: number, content: Buffer | string): UpdateRecorder;
60 remove(index: number, length: number): UpdateRecorder;
61}