-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
40 lines (35 loc) · 852 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var plist = require('plist')
/**
* Converts a loaded tmTheme file into a theme in VS Code format.
* The returned object can be passed to `JSON.stringify()` to produce a valid
* VS Code theme file.
* @return a javascript object
* @param {String} str - xml string (in plist format)
*/
function convertTheme(str) {
var theme = plist.parse(str)
theme.settings = convertArray(theme.settings)
return theme
}
function convertArray(a) {
for (var i = 0; i < a.length; i++) {
a[i] = convertObject(a[i])
}
return a
}
function convertObject(o) {
if (o.scope != null) {
return convertScopedSettings(o)
} else {
return o
}
}
function convertScopedSettings(o) {
if (o.scope.includes(',')) {
o.scope = o.scope.split(',').map(function(s) {
return s.trim()
})
}
return o
}
exports.convertTheme = convertTheme