/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular_devkit/build_angular/src/utils/copy-assets.ts
66 строк
2 KB
Ben McCann
refactor(@angular-devkit/build-angular): switch to tinyglobby
08 сен 2025, 13:39
08 сен 2025, 13:39
1de92cc
Код
Авторство
О чём код?
/** * @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 fs from 'node:fs'; import path from 'node:path'; import { glob } from 'tinyglobby'; export async function copyAssets( entries: { glob: string; ignore?: string[]; input: string; output: string; flatten?: boolean; followSymlinks?: boolean; }[], basePaths: Iterable<string>, root: string, changed?: Set<string>, ) { const defaultIgnore = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db']; const outputFiles: { source: string; destination: string }[] = []; for (const entry of entries) { const cwd = path.resolve(root, entry.input); const files = await glob(entry.glob, { cwd, dot: true, ignore: entry.ignore ? defaultIgnore.concat(entry.ignore) : defaultIgnore, followSymbolicLinks: entry.followSymlinks, }); const directoryExists = new Set<string>(); for (const file of files) { const src = path.join(cwd, file); if (changed && !changed.has(src)) { continue; } const filePath = entry.flatten ? path.basename(file) : file; outputFiles.push({ source: src, destination: path.join(entry.output, filePath) }); for (const base of basePaths) { const dest = path.join(base, entry.output, filePath); const dir = path.dirname(dest); if (!directoryExists.has(dir)) { if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); } directoryExists.add(dir); } fs.copyFileSync(src, dest, fs.constants.COPYFILE_FICLONE); } } } return outputFiles; }