Skip to content

Commit 4738238

Browse files
authored
Inline getPackageVersion Function (#252)
1 parent 5cd3608 commit 4738238

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/app/index.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,16 @@ module.exports = class TheiaExtension extends Base {
121121
description: 'The extension\'s Github URL',
122122
type: String
123123
});
124-
const latestTheiaVersion = this.getLatestPackageVersion('@theia/core');
124+
125+
let latestTheiaVersion = 'latest';
126+
try {
127+
// Run the npm command to get the latest version of @theia/core
128+
const result = execSync('npm show @theia/core version', { encoding: 'utf-8' });
129+
latestTheiaVersion = result.trim();
130+
} catch (error) {
131+
console.error('Error fetching the latest package version:', error);
132+
}
133+
125134
this.option('theia-version', {
126135
alias: 't',
127136
description: 'The version of Theia to use',
@@ -146,16 +155,6 @@ module.exports = class TheiaExtension extends Base {
146155
});
147156
}
148157

149-
getLatestPackageVersion(packageName: string): string {
150-
try {
151-
// Run the npm command to get the latest version of the package
152-
const result = execSync(`npm show ${packageName} version`, { encoding: 'utf-8' });
153-
return result.trim();
154-
} catch (error) {
155-
console.error('Error fetching the latest package version:', error);
156-
return 'latest';
157-
}
158-
}
159158

160159
path() {
161160
this.sourceRoot(__dirname + '/../../templates');

0 commit comments

Comments
 (0)