mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-25 20:24:04 +00:00
Add darwinBundleDocumentTypes
Split darwinBundleDocumentType into two separate functions. The first function is unchanged. The second function allows you to specify specific names for different groups of extensions while all sharing the same icon. For example, this would allow you to differentiate between a C header and a C source file while using the same icon for both. Inherently, the second function will generate multiple file type declarations, so it returns an array instead of a single object. As a result we must use the splat operator on it when passing the result to an array literal.
This commit is contained in:
@@ -67,6 +67,30 @@ function darwinBundleDocumentType(extensions: string[], icon: string, nameOrSuff
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate several `DarwinDocumentType`s with unique names and a shared icon.
|
||||
* @param types A map of file type names to their associated file extensions.
|
||||
* @param icon A darwin icon resource to use. For example, `'HTML'` would refer to `resources/darwin/html.icns`
|
||||
*
|
||||
* Examples:
|
||||
* ```
|
||||
* darwinBundleDocumentTypes({ 'C header file': 'h', 'C source code': 'c' },'c')
|
||||
* darwinBundleDocumentTypes({ 'React source code': ['jsx', 'tsx'] }, 'react')
|
||||
* ```
|
||||
*/
|
||||
function darwinBundleDocumentTypes(types: { [name: string]: string | string[] }, icon: string): DarwinDocumentType[] {
|
||||
return Object.keys(types).map((name: string): DarwinDocumentType => {
|
||||
const extensions = types[name];
|
||||
return {
|
||||
name: name,
|
||||
role: 'Editor',
|
||||
ostypes: ['TEXT', 'utxt', 'TUTX', '****'],
|
||||
extensions: Array.isArray(extensions) ? extensions : [extensions],
|
||||
iconFile: 'resources/darwin/' + icon + '.icns',
|
||||
} as DarwinDocumentType;
|
||||
});
|
||||
}
|
||||
|
||||
export const config = {
|
||||
version: util.getElectronVersion(),
|
||||
productAppName: product.nameLong,
|
||||
|
||||
Reference in New Issue
Block a user