
The previous implementation mixed up the management of locking a piece of code (both sync and async) with the management of writing and removing the lockFile that is used as the flag for which process has locked the code. This change splits these two concepts up. Apart from avoiding the awkward base class it allows the `LockFile` implementation to be replaced cleanly. PR Close #35861
25 lines
732 B
TypeScript
25 lines
732 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
import {FileSystem} from '../../../src/ngtsc/file_system';
|
|
import {LockFile} from '../../src/execution/lock_file';
|
|
|
|
/**
|
|
* A mock implementation of `LockFile` that just logs its calls.
|
|
*/
|
|
export class MockLockFile implements LockFile {
|
|
constructor(
|
|
fs: FileSystem, private log: string[] = [], public path = fs.resolve('/lockfile'),
|
|
private pid = '1234') {}
|
|
write() { this.log.push('write()'); }
|
|
read(): string {
|
|
this.log.push('read()');
|
|
return this.pid;
|
|
}
|
|
remove() { this.log.push('remove()'); }
|
|
}
|