Skip to content

Commit ce4d7af

Browse files
committed
fix(@angular-devkit/core): template tags for easier path and fileBuffer
This comes in handy in tests.
1 parent ecdddf7 commit ce4d7af

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

packages/angular_devkit/core/src/virtual-fs/host/buffer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ export function stringToFileBuffer(str: string): FileBuffer {
4646
}
4747
}
4848

49+
50+
export const fileBuffer: TemplateTag<FileBuffer> = (strings, ...values) => {
51+
return stringToFileBuffer(String.raw(strings, ...values));
52+
};
53+
54+
4955
export function fileBufferToString(fileBuffer: FileBuffer): string {
5056
if (fileBuffer.toString.length == 1) {
5157
return (fileBuffer.toString as (enc: string) => string)('utf-8');

packages/angular_devkit/core/src/virtual-fs/path.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { BaseException } from '../exception';
9+
import { TemplateTag } from '../utils/literals';
910

1011

1112
export class InvalidPathException extends BaseException {
@@ -250,6 +251,11 @@ export function normalize(path: string): Path {
250251
}
251252

252253

254+
export const path: TemplateTag<Path> = (strings, ...values) => {
255+
return normalize(String.raw(strings, ...values));
256+
};
257+
258+
253259
// Platform-specific paths.
254260
export type WindowsPath = string & {
255261
__PRIVATE_DEVKIT_WINDOWS_PATH: void;

0 commit comments

Comments
 (0)