forked from emmetio/emmet-atom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-menu.js
40 lines (35 loc) · 926 Bytes
/
generate-menu.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
// Generates Atom menu file from Emmet action list
var fs = require('fs');
var path = require('path');
var actions = require('emmet/lib/action/main');
function generateMenu(menu) {
return menu.map(function(item) {
if (item.type == 'action') {
return {
label: item.label,
command: 'emmet:' + item.name.replace(/_/g, '-')
};
}
if (item.type == 'submenu') {
return {
label: item.name,
submenu: generateMenu(item.items)
};
}
});
}
var menu = {
'menu': [{
label: 'Packages',
submenu: [{
label: 'Emmet',
submenu: generateMenu(actions.getMenu()).concat([{
label: 'Interactive Expand Abbreviation',
command: 'emmet:interactive-expand-abbreviation'
}])
}]
}]
};
var menuFile = path.join(__dirname, 'menus', 'emmet.json');
fs.writeFileSync(menuFile, JSON.stringify(menu, null, '\t'), {encoding: 'utf8'});
console.log('Menu file "%s" generated successfully', menuFile);