Paul Gschwendtner 9ea53803f7 build: create tool for validating typescript circular dependencies (#35647)
Creates a tool for validating TypeScript circular dependencies. The tool
has been designed in a way that allows us to slowly burn down the amount
of circular dependencies while ensuring that we don't regress.

The tool doesn't rely on Madge since it doesn't provide a programmatic
way for doing path mapping. We need path mapping since we also want to
check for cycles across different entry-points or packages. The tool
uses the TypeScript AST to manually collect cycles. This code is not
a lot of bloat and also gives us more flexibility (if we ever need it).

Closes #35041.

PR Close #35647
2020-03-17 12:27:06 -07:00

24 lines
634 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 {Stats, statSync} from 'fs';
/** Gets the status of the specified file. Returns null if the file does not exist. */
export function getFileStatus(filePath: string): Stats|null {
try {
return statSync(filePath);
} catch {
return null;
}
}
/** Ensures that the specified path uses forward slashes as delimiter. */
export function convertPathToForwardSlash(path: string) {
return path.replace(/\\/g, '/');
}