1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const fs_1 = require("fs");
|
4 | const path_1 = require("path");
|
5 | const pubsub_1 = require("./pubsub");
|
6 | const nconf = require.main.require('nconf');
|
7 | const baseDir = nconf.get('base_dir');
|
8 | const noop = () => { };
|
9 |
|
10 | const toggle = ({ id }, cb = noop) => {
|
11 | fs_1.readFile(path_1.join(baseDir, 'node_modules', id, 'plugin.json'), 'utf8', (err, file) => {
|
12 | if (err && err.code !== 'ENOENT') {
|
13 | cb(err);
|
14 | return;
|
15 | }
|
16 | if (err || !file) {
|
17 | cb();
|
18 | return;
|
19 | }
|
20 | let plugin;
|
21 | try {
|
22 | plugin = JSON.parse(file);
|
23 | }
|
24 | catch (e) {
|
25 | cb(e);
|
26 | return;
|
27 | }
|
28 | const hasHook = plugin.hooks && plugin.hooks
|
29 | .some((hook) => hook.hook === 'filter:emoji.packs');
|
30 | if (hasHook) {
|
31 | pubsub_1.build(cb);
|
32 | }
|
33 | });
|
34 | };
|
35 | exports.activation = toggle;
|
36 | exports.deactivation = toggle;
|
37 |
|
\ | No newline at end of file |