scan builtin extensions

This commit is contained in:
Sandeep Somavarapu
2020-06-22 15:38:07 +02:00
parent f816c23b22
commit 7bfb55ece5
2 changed files with 58 additions and 2 deletions

View File

@@ -78,7 +78,7 @@ function fromLocal(extensionPath: string, forWeb: boolean): Stream {
});
}
return minimizeLanguageJSON(input)
return minimizeLanguageJSON(input);
}
@@ -307,3 +307,35 @@ export function packageMarketplaceWebExtensionsStream(builtInExtensions: IBuiltI
});
return es.merge(extensions);
}
export interface IScannedBuiltinExtension {
extensionPath: string,
packageJSON: any,
packagsNLSPath?: string,
readmePath?: string,
changelogPath?: string,
}
export function scanBuiltinExtensions(extensionsRoot: string, forWeb: boolean): IScannedBuiltinExtension[] {
const scannedExtensions: IScannedBuiltinExtension[] = [];
const extensionsFolders = fs.readdirSync(extensionsRoot);
for (const extensionFolder of extensionsFolders) {
const packageJSON = JSON.parse(fs.readFileSync(path.join(extensionsRoot, extensionFolder, 'package.json')).toString('utf8'));
const extensionKind: string[] = packageJSON['extensionKind'] || [];
if (forWeb && extensionKind.indexOf('web') === -1) {
continue;
}
const children = fs.readdirSync(path.join(extensionsRoot, extensionFolder));
const packageNLS = children.filter(child => child === 'package.nls.json')[0];
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0];
scannedExtensions.push({
extensionPath: extensionFolder,
packageJSON: packageJSON,
packagsNLSPath: packageNLS ? path.join(extensionFolder, packageNLS) : undefined,
readmePath: readme ? path.join(extensionFolder, readme) : undefined,
changelogPath: changelog ? path.join(extensionFolder, changelog) : undefined,
});
}
return scannedExtensions;
}