Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions build/lib/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const darwinCreditsTemplate = product.darwinCredits && _.template(fs.readFileSyn
* If you call `darwinBundleDocumentType(..., 'bat', 'Windows command script')`, the file type is `"Windows command script"`,
* and the `'bat'` darwin icon is used.
*/
function darwinBundleDocumentType(extensions, icon, nameOrSuffix) {
function darwinBundleDocumentType(extensions, icon, nameOrSuffix, utis) {
// If given a suffix, generate a name from it. If not given anything, default to 'document'
if (isDocumentSuffix(nameOrSuffix) || !nameOrSuffix) {
nameOrSuffix = icon.charAt(0).toUpperCase() + icon.slice(1) + ' ' + (nameOrSuffix ?? 'document');
Expand All @@ -46,8 +46,9 @@ function darwinBundleDocumentType(extensions, icon, nameOrSuffix) {
name: nameOrSuffix,
role: 'Editor',
ostypes: ['TEXT', 'utxt', 'TUTX', '****'],
extensions: extensions,
iconFile: 'resources/darwin/' + icon + '.icns'
extensions,
iconFile: 'resources/darwin/' + icon + '.icns',
utis
};
}
/**
Expand All @@ -65,11 +66,11 @@ function darwinBundleDocumentTypes(types, icon) {
return Object.keys(types).map((name) => {
const extensions = types[name];
return {
name: name,
name,
role: 'Editor',
ostypes: ['TEXT', 'utxt', 'TUTX', '****'],
extensions: Array.isArray(extensions) ? extensions : [extensions],
iconFile: 'resources/darwin/' + icon + '.icns',
iconFile: 'resources/darwin/' + icon + '.icns'
};
});
}
Expand Down Expand Up @@ -156,7 +157,9 @@ exports.config = {
darwinBundleDocumentType([
'containerfile', 'ctp', 'dot', 'edn', 'handlebars', 'hbs', 'ml', 'mli',
'pl', 'pl6', 'pm', 'pm6', 'pod', 'pp', 'properties', 'psgi', 'rt', 't'
], 'default', product.nameLong + ' document')
], 'default', product.nameLong + ' document'),
// Folder support ()
darwinBundleDocumentType([], 'default', 'Folder', ['public.folder'])
],
darwinBundleURLTypes: [{
role: 'Viewer',
Expand Down
16 changes: 10 additions & 6 deletions build/lib/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type DarwinDocumentType = {
ostypes: string[];
extensions: string[];
iconFile: string;
utis?: string[];
};

function isDocumentSuffix(str?: string): str is DarwinDocumentSuffix {
Expand Down Expand Up @@ -50,7 +51,7 @@ const darwinCreditsTemplate = product.darwinCredits && _.template(fs.readFileSyn
* If you call `darwinBundleDocumentType(..., 'bat', 'Windows command script')`, the file type is `"Windows command script"`,
* and the `'bat'` darwin icon is used.
*/
function darwinBundleDocumentType(extensions: string[], icon: string, nameOrSuffix?: string | DarwinDocumentSuffix): DarwinDocumentType {
function darwinBundleDocumentType(extensions: string[], icon: string, nameOrSuffix?: string | DarwinDocumentSuffix, utis?: string[]): DarwinDocumentType {
// If given a suffix, generate a name from it. If not given anything, default to 'document'
if (isDocumentSuffix(nameOrSuffix) || !nameOrSuffix) {
nameOrSuffix = icon.charAt(0).toUpperCase() + icon.slice(1) + ' ' + (nameOrSuffix ?? 'document');
Expand All @@ -60,8 +61,9 @@ function darwinBundleDocumentType(extensions: string[], icon: string, nameOrSuff
name: nameOrSuffix,
role: 'Editor',
ostypes: ['TEXT', 'utxt', 'TUTX', '****'],
extensions: extensions,
iconFile: 'resources/darwin/' + icon + '.icns'
extensions,
iconFile: 'resources/darwin/' + icon + '.icns',
utis
};
}

Expand All @@ -80,11 +82,11 @@ function darwinBundleDocumentTypes(types: { [name: string]: string | string[] },
return Object.keys(types).map((name: string): DarwinDocumentType => {
const extensions = types[name];
return {
name: name,
name,
role: 'Editor',
ostypes: ['TEXT', 'utxt', 'TUTX', '****'],
extensions: Array.isArray(extensions) ? extensions : [extensions],
iconFile: 'resources/darwin/' + icon + '.icns',
iconFile: 'resources/darwin/' + icon + '.icns'
} as DarwinDocumentType;
});
}
Expand Down Expand Up @@ -172,7 +174,9 @@ export const config = {
darwinBundleDocumentType([
'containerfile', 'ctp', 'dot', 'edn', 'handlebars', 'hbs', 'ml', 'mli',
'pl', 'pl6', 'pm', 'pm6', 'pod', 'pp', 'properties', 'psgi', 'rt', 't'
], 'default', product.nameLong + ' document')
], 'default', product.nameLong + ' document'),
// Folder support ()
darwinBundleDocumentType([], 'default', 'Folder', ['public.folder'])
],
darwinBundleURLTypes: [{
role: 'Viewer',
Expand Down