Spaces:
Sleeping
Sleeping
File size: 1,090 Bytes
61d39e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
//@extension name extension
const { Context } = extension.import('core');
// The 'create.commands' event is fired by CommandService
extension.on('create.commands', event => {
// Add command to list available extensions
event.createCommand('list', {
description: 'list available extensions',
handler: async (_, console) => {
// Get extnsion information from context
const extensionInfos = Context.get('extensionInfo');
// Iterate over extension infos
for ( const info of Object.values(extensionInfos) ) {
// Construct a string
const moduleType = info.type === 'module'
? '\x1B[32;1m(ESM)\x1B[0m'
: '\x1B[33;1m(CJS)\x1B[0m';
let str = `- ${info.name} ${moduleType}`;
if ( info.priority !== 0 ) {
str += ` (priority ${info.priority})`;
}
// Print a string
console.log(str);
}
},
});
});
|