Pete Bacon Darwin a107e9edc6 feat(ngcc): lock ngcc when processing (#34722)
Previously, it was possible for multiple instance of ngcc to be running
at the same time, but this is not supported and can cause confusing and
flakey errors at build time.

Now, only one instance of ngcc can run at a time. If a second instance
tries to execute it fails with an appropriate error message.

See https://github.com/angular/angular/issues/32431#issuecomment-571825781

PR Close #34722
2020-01-22 15:35:34 -08:00

27 lines
975 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 {MockFileSystemNative} from '../../../src/ngtsc/file_system/testing';
import {LockFile} from '../../src/execution/lock_file';
export class MockLockFile extends LockFile {
log: string[] = [];
constructor(private options: {throwOnCreate?: boolean, throwOnRemove?: boolean} = {}) {
// This `MockLockFile` is not used in tests that are run via `runInEachFileSystem()`
// So we cannot use `getFileSystem()` but instead just instantiate a mock file-system.
super(new MockFileSystemNative());
}
create() {
this.log.push('create()');
if (this.options.throwOnCreate) throw new Error('LockFile.create() error');
}
remove() {
this.log.push('remove()');
if (this.options.throwOnRemove) throw new Error('LockFile.remove() error');
}
}