Skip to content

Commit b5e3d43

Browse files
committed
The List imports command now also find the require(...) packages.
1 parent 6fd1a1d commit b5e3d43

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## Version 1.1.0
4+
5+
- Bugfix: The List imports command now also find the require(...) packages.
6+
37
## Version 1.0.1
48

59
- Bugfix: The Show component hierarchy graph command did not work

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "vscode-angulartools",
33
"publisher": "coderAllan",
44
"displayName": "AngularTools",
5-
"description": "AngularTools is a collection of tools for exploring an Angular project, help you with documenting, reverse engineering a project or help when refactoring.",
6-
"icon": "images/logo.png",
7-
"version": "1.0.1",
5+
"description": "AngularTools is a collection of tools for exploring an Angular project, help you with documenting, reverse engineering a project or help when refactoring.",
6+
"icon": "images/logo.png",
7+
"version": "1.1.0",
88
"repository": "https://github.com/CoderAllan/vscode-angulartools",
99
"author": {
1010
"name": "Allan Simonsen",
@@ -14,12 +14,15 @@
1414
"vscode": "^1.49.0"
1515
},
1616
"categories": [
17-
"Other",
18-
"Visualization"
19-
],
20-
"keywords": [
21-
"angular", "dgml", "typescript", "markdown"
22-
],
17+
"Other",
18+
"Visualization"
19+
],
20+
"keywords": [
21+
"angular",
22+
"dgml",
23+
"typescript",
24+
"markdown"
25+
],
2326
"activationEvents": [
2427
"onCommand:angulartools.componentHierarchyDgml",
2528
"onCommand:angulartools.listAllImports",

src/commands/listAllImports.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@ export class ListAllImports {
2323
if (!results) { return; }
2424
for (let i = 0; i < results.length; i++) {
2525
var file = results[i];
26-
const regex: RegExp = new RegExp('.*?\\s+from\\s+[\'"](.+)[\'"]', 'ig');
26+
const regexImports: RegExp = new RegExp('.*?\\s+from\\s+[\'"](.+)[\'"]', 'ig');
27+
const regexRequires: RegExp = new RegExp('.*?\\s+require\\s*\\(\\s*[\'"](.+)[\'"]\\s*\\)', 'ig');
2728
const content = fs.readFileSync(file, 'utf8');
2829
const lines: string[] = content.split('\n');
2930
lines.forEach(line => {
30-
const match = regex.exec(line);
31-
if (match) {
32-
const key = match[1];
31+
const matchImports = regexImports.exec(line);
32+
const matchRequires = regexRequires.exec(line);
33+
if (matchImports || matchRequires) {
34+
let key: string = '';
35+
if (matchImports) {
36+
key = matchImports[1];
37+
}
38+
if (matchRequires) {
39+
key = matchRequires[1];
40+
}
3341
if (imports.hasOwnProperty(key)) {
3442
imports[key] = imports[key] + 1;
3543
} else {

0 commit comments

Comments
 (0)