@@ -2,6 +2,7 @@ import * as fs from 'fs';
2
2
import * as vscode from 'vscode' ;
3
3
import * as path from 'path' ;
4
4
import { ArrayUtils , Config , FileSystemUtils } from '@src' ;
5
+ import { CommandBase } from '@commands' ;
5
6
6
7
export interface INgModule {
7
8
imports : string [ ] ;
@@ -34,11 +35,12 @@ export class NgModule implements INgModule {
34
35
}
35
36
}
36
37
37
- export class ModulesToMarkdown {
38
+ export class ModulesToMarkdown extends CommandBase {
38
39
private config = new Config ( ) ;
39
40
public static get commandName ( ) : string { return 'modulesToMarkdown' ; }
40
41
41
42
public execute ( ) {
43
+ this . checkForOpenWorkspace ( ) ;
42
44
const fsUtils = new FileSystemUtils ( ) ;
43
45
var workspaceDirectory : string = fsUtils . getWorkspaceFolder ( ) ;
44
46
const filenames = fsUtils . listFiles ( workspaceDirectory , this . config . excludeDirectories , this . isTypescriptFile ) ;
@@ -67,10 +69,6 @@ export class ModulesToMarkdown {
67
69
fsUtils . writeFileAndOpen ( path . join ( workspaceDirectory , this . config . modulesToMarkdownFilename ) , markdownContent ) ;
68
70
}
69
71
70
- private isTypescriptFile ( filename : string ) : boolean {
71
- return filename . endsWith ( '.ts' ) && ! filename . endsWith ( 'index.ts' ) ;
72
- }
73
-
74
72
private readModule ( filename : string , errors : string [ ] ) : NgModule | undefined {
75
73
const fileContents = fs . readFileSync ( filename ) ;
76
74
const regex : RegExp = / @ N g M o d u l e \s * \( \s * ( \{ .+ ?\} ) \s * \) \s * e x p o r t \s + c l a s s \s + ( \w + ) \s * \{ / ims;
0 commit comments