-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (24 loc) · 931 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
var path = require('path'),
fs = require('fs'),
yaml = require('js-yaml');
class Places {
constructor(config) {
config.addJS('/node_modules/kosmtik-places/front.js');
config.addCSS('/node_modules/kosmtik-places/front.css');
config.on('project:tofront', this.patchConfig);
}
patchConfig(e) {
var filepath = path.join(e.project.root, 'bookmarks.yml');
if (fs.existsSync(filepath)) {
try {
e.options.places = yaml.safeLoad(fs.readFileSync(filepath, 'utf8'));
console.log('[Places] Loaded bookmarks from', filepath);
} catch (e) {
console.log('[Places] Unable to load bookmarks from', filepath);
e.options.places = [];
}
}
e.options.places = e.options.places.concat(this.userConfig.bookmarks || []);
};
}
exports = module.exports = { Plugin: Places };