/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular_devkit/schematics/src/rules/move.ts
41 строка
1002 B
Matthieu Riegler
feat(@schematics/angular): add schematics to generate ai context files.
13 авг 2025, 16:58
13 авг 2025, 16:58
d80dae2
Код
Авторство
О чём код?
/** * @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, normalize } from '@angular-devkit/core'; import { Rule } from '../engine/interface'; import { noop } from './base'; export function move(from: string, to: string): Rule; export function move(to: string): Rule; export function move(from: string, to?: string): Rule { if (to === undefined) { to = from; from = '/'; } const fromPath = normalize('/' + from); const toPath = normalize('/' + to); if (fromPath === toPath) { return noop; } return (tree) => { if (tree.exists(fromPath)) { // fromPath is a file tree.rename(fromPath, toPath); } else { // fromPath is a directory tree.getDir(fromPath).visit((path) => { tree.rename(path, join(toPath, path.slice(fromPath.length))); }); } return tree; }; }