/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular/build/src/utils/project-metadata.ts
37 строк
1 KB
Alan Agius
refactor: modernize array and string last element access using `.at(-1)`
20 ноя 2025, 18:00
Не верифицирован
20 ноя 2025, 18:00
2671945
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC 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.dev/license */ import { join } from 'node:path'; /** * Normalize a directory path string. * Currently only removes a trailing slash if present. * @param path A path string. * @returns A normalized path string. */ export function normalizeDirectoryPath(path: string): string { const last = path.at(-1); if (last === '/' || last === '\\') { return path.slice(0, -1); } return path; } export function getProjectRootPaths( workspaceRoot: string, projectMetadata: { root?: string; sourceRoot?: string }, ) { const projectRoot = normalizeDirectoryPath(join(workspaceRoot, projectMetadata.root ?? '')); const rawSourceRoot = projectMetadata.sourceRoot; const projectSourceRoot = normalizeDirectoryPath( rawSourceRoot === undefined ? join(projectRoot, 'src') : join(workspaceRoot, rawSourceRoot), ); return { projectRoot, projectSourceRoot }; }