-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpostinstall.js
29 lines (24 loc) · 902 Bytes
/
postinstall.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
const path = require('path');
const fs = require('fs-extra');
const pluginConfig = require('./config.json');
const { pluginName } = require('./src/plugin-info');
console.log(`Installing Pattern Lab Node Plugin - "${pluginName}". `);
const patternLabCofigName = 'patternlab-config.json';
const configPath = path.resolve(`./${patternLabCofigName}`);
try {
const plConfig = fs.readJSONSync(configPath);
if (!plConfig.plugins) {
plConfig.plugins = {};
}
if (!plConfig.plugins[pluginName]) {
plConfig.plugins[pluginName] = pluginConfig;
fs.outputJSONSync(configPath, plConfig, { spaces: 2 });
console.log(
`Added "${pluginName}" config to ${patternLabCofigName} at plugins config.`
);
}
} catch (e) {}
console.log(`Pattern Lab Node Plugin - "${pluginName}" installed. `);
console.log(
'Configure or disable this plugin inside your patternlab-config.json file.'
);