Skip to content

Commit 65b4134

Browse files
authored
Merge pull request microsoft#95637 from luqmana/workspace-mimetype
Register mimetype for *.code-workspace
2 parents f4833ee + 828389d commit 65b4134

6 files changed

Lines changed: 39 additions & 4 deletions

File tree

build/gulpfile.vscode.linux.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ function prepareDebPackage(arch) {
5252
.pipe(replace('@@LICENSE@@', product.licenseName))
5353
.pipe(rename('usr/share/appdata/' + product.applicationName + '.appdata.xml'));
5454

55+
const workspaceMime = gulp.src('resources/code-workspace.xml', { base: '.' })
56+
.pipe(replace('@@NAME_LONG@@', product.nameLong))
57+
.pipe(replace('@@NAME@@', product.applicationName))
58+
.pipe(rename('usr/share/mime/packages/' + product.applicationName + '-workspace.xml'));
59+
5560
const icon = gulp.src('resources/linux/code.png', { base: '.' })
5661
.pipe(rename('usr/share/pixmaps/' + product.linuxIconName + '.png'));
5762

@@ -95,7 +100,7 @@ function prepareDebPackage(arch) {
95100
.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
96101
.pipe(rename('DEBIAN/postinst'));
97102

98-
const all = es.merge(control, postinst, postrm, prerm, desktops, appdata, icon, bash_completion, zsh_completion, code);
103+
const all = es.merge(control, postinst, postrm, prerm, desktops, appdata, workspaceMime, icon, bash_completion, zsh_completion, code);
99104

100105
return all.pipe(vfs.dest(destination));
101106
};
@@ -143,6 +148,11 @@ function prepareRpmPackage(arch) {
143148
.pipe(replace('@@LICENSE@@', product.licenseName))
144149
.pipe(rename('usr/share/appdata/' + product.applicationName + '.appdata.xml'));
145150

151+
const workspaceMime = gulp.src('resources/code-workspace.xml', { base: '.' })
152+
.pipe(replace('@@NAME_LONG@@', product.nameLong))
153+
.pipe(replace('@@NAME@@', product.applicationName))
154+
.pipe(rename('BUILD/usr/share/mime/packages/' + product.applicationName + '-workspace.xml'));
155+
146156
const icon = gulp.src('resources/linux/code.png', { base: '.' })
147157
.pipe(rename('BUILD/usr/share/pixmaps/' + product.linuxIconName + '.png'));
148158

@@ -173,7 +183,7 @@ function prepareRpmPackage(arch) {
173183
const specIcon = gulp.src('resources/linux/rpm/code.xpm', { base: '.' })
174184
.pipe(rename('SOURCES/' + product.applicationName + '.xpm'));
175185

176-
const all = es.merge(code, desktops, appdata, icon, bash_completion, zsh_completion, spec, specIcon);
186+
const all = es.merge(code, desktops, appdata, workspaceMime, icon, bash_completion, zsh_completion, spec, specIcon);
177187

178188
return all.pipe(vfs.dest(getRpmBuildPath(rpmArch)));
179189
};

resources/linux/code-workspace.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
3+
<mime-type type="application/x-@@NAME@@-workspace">
4+
<comment>@@NAME_LONG@@ Workspace</comment>
5+
<glob pattern="*.code-workspace"/>
6+
</mime-type>
7+
</mime-info>

resources/linux/code.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Type=Application
88
StartupNotify=false
99
StartupWMClass=@@NAME_SHORT@@
1010
Categories=Utility;TextEditor;Development;IDE;
11-
MimeType=text/plain;inode/directory;
11+
MimeType=text/plain;inode/directory;application/x-@@NAME@@-workspace;
1212
Actions=new-empty-window;
1313
Keywords=vscode;
1414

resources/linux/debian/postinst.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ if hash desktop-file-install 2>/dev/null; then
1818
desktop-file-install /usr/share/applications/@@NAME@@-url-handler.desktop
1919
fi
2020

21+
# Update mimetype database to pickup workspace mimetype
22+
if hash update-mime-database 2>/dev/null; then
23+
update-mime-database /usr/share/mime
24+
fi
25+
2126
if [ "@@NAME@@" != "code-oss" ]; then
2227
# Remove the legacy bin command if this is the stable build
2328
if [ "@@NAME@@" = "code" ]; then

resources/linux/debian/postrm.template

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# Licensed under the MIT License. See License.txt in the project root for license information.
55

6-
rm -f /usr/bin/@@NAME@@
6+
rm -f /usr/bin/@@NAME@@
7+
8+
# Update mimetype database for removed workspace mimetype
9+
if hash update-mime-database 2>/dev/null; then
10+
update-mime-database /usr/share/mime
11+
fi

resources/linux/rpm/code.spec.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mkdir -p %{buildroot}/usr/share/zsh/site-functions
2323
cp -r usr/share/@@NAME@@/* %{buildroot}/usr/share/@@NAME@@
2424
cp -r usr/share/applications/@@NAME@@.desktop %{buildroot}/usr/share/applications
2525
cp -r usr/share/applications/@@NAME@@-url-handler.desktop %{buildroot}/usr/share/applications
26+
cp -r usr/share/mime/packages/@@NAME@@-workspace.xml %{buildroot}/usr/share/mime/packages/@@NAME-workspace.xml
2627
cp -r usr/share/pixmaps/@@ICON@@.png %{buildroot}/usr/share/pixmaps
2728
cp usr/share/bash-completion/completions/@@NAME@@ %{buildroot}/usr/share/bash-completion/completions/@@NAME@@
2829
cp usr/share/zsh/site-functions/_@@NAME@@ %{buildroot}/usr/share/zsh/site-functions/_@@NAME@@
@@ -46,17 +47,24 @@ ln -sf /usr/share/@@NAME@@/bin/@@NAME@@ %{_bindir}/@@NAME@@
4647
# fi
4748
#fi
4849

50+
# Update mimetype database to pickup workspace mimetype
51+
update-mime-database /usr/share/mime &> /dev/null || :
52+
4953
%postun
5054
if [ $1 = 0 ]; then
5155
rm -f /usr/bin/@@NAME@@
5256
fi
5357

58+
# Update mimetype database for removed workspace mimetype
59+
update-mime-database /usr/share/mime &> /dev/null || :
60+
5461
%files
5562
%defattr(-,root,root)
5663

5764
/usr/share/@@NAME@@/
5865
/usr/share/applications/@@NAME@@.desktop
5966
/usr/share/applications/@@NAME@@-url-handler.desktop
67+
/usr/share/mime/packages/@@NAME-workspace.xml
6068
/usr/share/pixmaps/@@ICON@@.png
6169
/usr/share/bash-completion/completions/@@NAME@@
6270
/usr/share/zsh/site-functions/_@@NAME@@

0 commit comments

Comments
 (0)