forked from cncsc/semantic-release-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassets.js
40 lines (31 loc) · 1.2 KB
/
assets.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
const fs = require('fs');
const { getPackageConfig, findPlugin } = require('./utils.js');
const config = require('./base.js');
function getAssets() {
const assets = [];
const packageConf = getPackageConfig();
if (!packageConf || !packageConf.assets || packageConf.assets.length === 0) {
return assets;
}
const packageAssets = Array.isArray(packageConf.assets) ? packageConf.assets : [];
packageAssets.filter(asset => !fs.existsSync(asset.path)).forEach(asset => {
console.warn(`Skipping assets: ${JSON.stringify(asset)}`);
});
packageAssets.filter(asset => fs.existsSync(asset.path)).forEach(asset => {
console.debug(`Adding assets: ${JSON.stringify(asset)}`);
assets.push(asset);
});
return assets;
}
function updateConfig(configuration) {
const pluginName = '@semantic-release/github';
const githubPlugin = findPlugin(configuration.plugins, pluginName);
if (!githubPlugin || githubPlugin.length !== 2) {
// no configuration - this should not happen as base should set a configuration for this plugin
return;
}
const assets = getAssets();
githubPlugin[1].assets = [...assets, ...(githubPlugin[1].assets || [])];
}
updateConfig(config);
module.exports = config;