forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoutput-paths.ts
28 lines (24 loc) · 853 Bytes
/
output-paths.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* @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 { existsSync, mkdirSync } from 'node:fs';
import { join } from 'node:path';
import { I18nOptions } from './i18n-webpack';
export function ensureOutputPaths(baseOutputPath: string, i18n: I18nOptions): Map<string, string> {
const outputPaths: [string, string][] = i18n.shouldInline
? [...i18n.inlineLocales].map((l) => [
l,
i18n.flatOutput ? baseOutputPath : join(baseOutputPath, i18n.locales[l].subPath),
])
: [['', baseOutputPath]];
for (const [, outputPath] of outputPaths) {
if (!existsSync(outputPath)) {
mkdirSync(outputPath, { recursive: true });
}
}
return new Map(outputPaths);
}