How to use the @ts-morph/common.FileUtils.isRootDirPath function in @ts-morph/common

To help you get started, we’ve selected a few @ts-morph/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dsherret / ts-morph / packages / ts-morph / src / factories / DirectoryCache.ts View on Github external
private removeFromDirectoriesByDirPath(dirPath: string) {
        if (FileUtils.isRootDirPath(dirPath))
            return;
        const parentDirPath = FileUtils.getDirPath(dirPath);
        const directories = this.directoriesByDirPath.get(parentDirPath);
        if (directories == null)
            return;
        directories.removeByKey(FileUtils.getBaseName(dirPath));

        // clean up
        if (!directories.hasItems())
            this.directoriesByDirPath.removeByKey(parentDirPath);
    }
github dsherret / ts-morph / packages / ts-morph / src / factories / InProjectCoordinator.ts View on Github external
function* getAncestorsUpToOneInProject(dir: Directory): IterableIterator {
            if (FileUtils.isRootDirPath(dir.getPath()))
                return;
            const parentDirPath = FileUtils.getDirPath(dir.getPath());
            const parentDir = compilerFactory.getDirectoryFromCacheOnlyIfInCache(parentDirPath);
            if (parentDir == null)
                return;

            yield parentDir;

            if (!inProjectCoordinator.isDirectoryInProject(parentDir))
                yield* getAncestorsUpToOneInProject(parentDir);
        }
    }
github dsherret / ts-morph / packages / ts-morph / src / factories / DirectoryCache.ts View on Github external
private addToDirectoriesByDirPath(directory: Directory) {
        if (FileUtils.isRootDirPath(directory.getPath()))
            return;
        const parentDirPath = FileUtils.getDirPath(directory.getPath());
        const directories = this.directoriesByDirPath.getOrCreate(parentDirPath,
            () => new SortedKeyValueArray(item => item.getBaseName(), LocaleStringComparer.instance));
        directories.set(directory);
    }