Skip to content

Commit 6e5d6fd

Browse files
committed
Improved version detection and optimised plugin
1 parent d1b176f commit 6e5d6fd

File tree

6 files changed

+28
-135
lines changed

6 files changed

+28
-135
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,6 @@ dist
104104
.tern-port
105105

106106
# Local history directory
107-
.lh/
107+
.lh/
108+
109+
out/

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to the "magento-2-version-in-vscode" extension will be docum
44

55
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

7+
8+
## 0.0.4
9+
10+
Improved and bug fixes
11+
712
## 0.0.2.1
813

914
- Fixed npm severity vulnerability
@@ -16,4 +21,4 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1621

1722
## 0.0.1
1823

19-
- Initial release
24+
- Initial release

out/extension.js

Lines changed: 0 additions & 120 deletions
This file was deleted.

out/extension.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Magento 2 version in VSCode",
44
"description": "Check Magento 2 in VS Code",
55
"publisher": "ananth-iyer",
6-
"version": "0.0.3",
6+
"version": "0.0.4",
77
"engines": {
88
"vscode": "^1.45.0"
99
},
@@ -12,7 +12,7 @@
1212
],
1313
"icon": "icon.png",
1414
"activationEvents": [
15-
"*"
15+
"onStartupFinished"
1616
],
1717
"main": "./out/extension.js",
1818
"scripts": {

src/extension.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ function updateStatusBarItem(): void {
6464
}
6565

6666
const cmp = require(p);
67+
if (!cmp || !cmp.name) {
68+
return;
69+
}
6770
const n = cmp.name.trim().split('/');
6871

6972
if (typeof n[1] !== "string") {
@@ -92,11 +95,15 @@ function updateStatusBarItem(): void {
9295
version = req['magento/project-enterprise-edition'] || version;
9396

9497
let name = '';
95-
for (const repo of repositories) {
96-
if (repo['url'].search('mage-os') >= 0) {
97-
name = 'MageOS';
98-
break;
99-
}
98+
var rp = Object.values(repositories);
99+
100+
const find = rp.find(function (v) {
101+
// @ts-ignore
102+
return v.url.search('mage-os') >= 0;
103+
});
104+
105+
if (find) {
106+
name = 'MageOS';
100107
}
101108

102109
if (!name) {
@@ -113,11 +120,11 @@ function updateStatusBarItem(): void {
113120
}
114121

115122
if (version === undefined && name === '') {
116-
version = '';
123+
version = 'No Magento';
117124
name = '';
118125
statusBarItem.text = '';
119126
statusBarItem.tooltip = '';
120-
statusBarItem.hide();
127+
// statusBarItem.hide();
121128
return;
122129
}
123130

@@ -128,9 +135,9 @@ function updateStatusBarItem(): void {
128135
}
129136

130137
function hideStatusBarItem() {
131-
statusBarItem.text = '';
132-
statusBarItem.tooltip = '';
133-
statusBarItem.hide();
138+
statusBarItem.text = 'No Magento';
139+
statusBarItem.tooltip = 'No Magento';
140+
// statusBarItem.hide();
134141
}
135142

136143
// this method is called when your extension is deactivated

0 commit comments

Comments
 (0)