Commit c8d957d9 authored by Philip Withnall's avatar Philip Withnall Committed by Bastien Nocera
Browse files

Add shebang magic for gjs JavaScript files

When writing scripts with gjs, it’s possible to write a program with no
`.js` suffix, but with a shebang line which invokes gjs. Add some magic
to detect that as application/x-javascript.

https://bugs.freedesktop.org/show_bug.cgi?id=99473
parent 8d771b23
......@@ -2385,6 +2385,18 @@ command to generate the output files.
<alias type="text/javascript"/>
<sub-class-of type="application/ecmascript"/>
<generic-icon name="text-x-script"/>
<magic priority="50">
<match type="string" value="#!/bin/gjs" offset="0"/>
<match type="string" value="#! /bin/gjs" offset="0"/>
<match type="string" value='eval \"exec /bin/gjs' offset="0"/>
<match type="string" value="#!/usr/bin/gjs" offset="0"/>
<match type="string" value="#! /usr/bin/gjs" offset="0"/>
<match type="string" value='eval \"exec /usr/bin/gjs' offset="0"/>
<match type="string" value="#!/usr/local/bin/gjs" offset="0"/>
<match type="string" value="#! /usr/local/bin/gjs" offset="0"/>
<match type="string" value='eval \"exec /usr/local/bin/gjs' offset="0"/>
<match type="string" value='/bin/env gjs' offset="2:16"/>
</magic>
<glob pattern="*.js"/>
<glob pattern="*.jsm"/>
</mime-type>
......
#!/usr/bin/env gjs
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const System = imports.system;
/* Some JavaScript happens here */
......@@ -227,6 +227,7 @@ helloworld.java text/x-java ox
survey.js application/javascript ox
# Copied from gecko/accessible/src/jsat/Utils.jsm in Boot2Gecko
Utils.jsm application/javascript ox
javascript-without-extension application/javascript xoo
# The following two copied from RFC 4627.
json_object.json application/json ox
json_array.json application/json ox
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment