Skip to content

Commit c8e5025

Browse files
committed
Added StringUtils
1 parent 9cd5221 commit c8e5025

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export * from './dgmlManager';
55
export * from './filesystemUtils';
66
export * from './graphvizManager';
77
export * from './moduleManager';
8+
export * from './stringUtils';

src/moduleManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs';
2-
import { ArrayUtils, Config, FileSystemUtils } from "@src";
2+
import { ArrayUtils, Config, FileSystemUtils, StringUtils } from "@src";
33
import { Component, Directive, Injectable, NamedEntity, NgModule, Pipe, Project } from '@model';
44

55
export class ModuleManager {
@@ -128,7 +128,7 @@ export class ModuleManager {
128128
}
129129

130130
private static parseModuleContents(moduleContents: string): NgModule {
131-
moduleContents = moduleContents.replace(/\s*?\/\/.*$/igm, () => ''); // Remove comments
131+
moduleContents = StringUtils.removeComments(moduleContents);
132132
const module = new NgModule();
133133
let section = this.getSection(moduleContents, 'imports');
134134
if (section.length > 0) {

src/stringUtils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
export class StringUtils {
3+
private static lineCommentRegex = /\s*?\/\/.*$/igm;
4+
private static blockCommentRegex = /\/\*.*?\*\//igm;
5+
6+
public static removeComments(content: string): string {
7+
content = content.replace(StringUtils.lineCommentRegex, () => ''); // Remove comments
8+
content = content.replace(StringUtils.blockCommentRegex, () => ''); // Remove comments
9+
return content;
10+
}
11+
}

0 commit comments

Comments
 (0)