Skip to content

Commit

Permalink
fix(@angular-devkit/core): template tags for easier path and fileBuffer
Browse files Browse the repository at this point in the history
This comes in handy in tests.
  • Loading branch information
hansl committed Jun 6, 2018
1 parent ecdddf7 commit ce4d7af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/angular_devkit/core/src/virtual-fs/host/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export function stringToFileBuffer(str: string): FileBuffer {
}
}


export const fileBuffer: TemplateTag<FileBuffer> = (strings, ...values) => {
return stringToFileBuffer(String.raw(strings, ...values));
};


export function fileBufferToString(fileBuffer: FileBuffer): string {
if (fileBuffer.toString.length == 1) {
return (fileBuffer.toString as (enc: string) => string)('utf-8');
Expand Down
6 changes: 6 additions & 0 deletions packages/angular_devkit/core/src/virtual-fs/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import { BaseException } from '../exception';
import { TemplateTag } from '../utils/literals';


export class InvalidPathException extends BaseException {
Expand Down Expand Up @@ -250,6 +251,11 @@ export function normalize(path: string): Path {
}


export const path: TemplateTag<Path> = (strings, ...values) => {
return normalize(String.raw(strings, ...values));
};


// Platform-specific paths.
export type WindowsPath = string & {
__PRIVATE_DEVKIT_WINDOWS_PATH: void;
Expand Down

0 comments on commit ce4d7af

Please sign in to comment.