1 | /// <amd-module name="@angular/compiler-cli/ngcc/src/locking/lock_file_with_child_process/index" />
|
---|
2 | /// <reference types="node" />
|
---|
3 | /**
|
---|
4 | * @license
|
---|
5 | * Copyright Google LLC All Rights Reserved.
|
---|
6 | *
|
---|
7 | * Use of this source code is governed by an MIT-style license that can be
|
---|
8 | * found in the LICENSE file at https://angular.io/license
|
---|
9 | */
|
---|
10 | import { ChildProcess } from 'child_process';
|
---|
11 | import { AbsoluteFsPath, FileSystem } from '../../../../src/ngtsc/file_system';
|
---|
12 | import { Logger } from '../../../../src/ngtsc/logging';
|
---|
13 | import { LockFile } from '../lock_file';
|
---|
14 | /**
|
---|
15 | * This `LockFile` implementation uses a child-process to remove the lock file when the main process
|
---|
16 | * exits (for whatever reason).
|
---|
17 | *
|
---|
18 | * There are a few milliseconds between the child-process being forked and it registering its
|
---|
19 | * `disconnect` event, which is responsible for tidying up the lock-file in the event that the main
|
---|
20 | * process exits unexpectedly.
|
---|
21 | *
|
---|
22 | * We eagerly create the unlocker child-process so that it maximizes the time before the lock-file
|
---|
23 | * is actually written, which makes it very unlikely that the unlocker would not be ready in the
|
---|
24 | * case that the developer hits Ctrl-C or closes the terminal within a fraction of a second of the
|
---|
25 | * lock-file being created.
|
---|
26 | *
|
---|
27 | * The worst case scenario is that ngcc is killed too quickly and leaves behind an orphaned
|
---|
28 | * lock-file. In which case the next ngcc run will display a helpful error message about deleting
|
---|
29 | * the lock-file.
|
---|
30 | */
|
---|
31 | export declare class LockFileWithChildProcess implements LockFile {
|
---|
32 | protected fs: FileSystem;
|
---|
33 | protected logger: Logger;
|
---|
34 | path: AbsoluteFsPath;
|
---|
35 | private unlocker;
|
---|
36 | constructor(fs: FileSystem, logger: Logger);
|
---|
37 | write(): void;
|
---|
38 | read(): string;
|
---|
39 | remove(): void;
|
---|
40 | protected createUnlocker(path: AbsoluteFsPath): ChildProcess;
|
---|
41 | }
|
---|