5
0
Fork 0
mirror of https://github.com/cycjimmy/semantic-release-action.git synced 2025-11-07 18:56:56 +00:00

refactor(inputs): remove redundant defaults and options

This commit is contained in:
cycjimmy 2019-10-26 22:40:30 +08:00
parent fd6487c160
commit 18455e9e99
4 changed files with 18 additions and 17 deletions

View file

@ -10,10 +10,8 @@ inputs:
default: master default: master
extra_plugins: extra_plugins:
description: 'Extra plugins for pre-install' description: 'Extra plugins for pre-install'
default: ''
dry_run: dry_run:
description: 'Whether to run semantic release in "dry-run" mode. It will override the dryRun attribute in your configuration file' description: 'Whether to run semantic release in "dry-run" mode. It will override the dryRun attribute in your configuration file'
default: ''
outputs: outputs:
new_release_published: new_release_published:
description: 'Whether a new release was published' description: 'Whether a new release was published'

View file

@ -6,7 +6,7 @@ const inputs = require('./inputs.json');
* @returns {{}|{dryRun: boolean}} * @returns {{}|{dryRun: boolean}}
*/ */
exports.handleDryRunOption = () => { exports.handleDryRunOption = () => {
const dryRun = core.getInput(inputs.dry_run, {required: false}) || ''; const dryRun = core.getInput(inputs.dry_run);
switch (dryRun) { switch (dryRun) {
case 'true': case 'true':

View file

@ -16,7 +16,7 @@ const release = async () => {
await setUpJob(); await setUpJob();
await preInstallPlugins(); await preInstallPlugins();
const branch = core.getInput(inputs.branch, {required: false}) || 'master'; const branch = core.getInput(inputs.branch) || 'master';
const result = await semanticRelease({ const result = await semanticRelease({
branch, branch,
...(handleDryRunOption()), ...(handleDryRunOption()),

View file

@ -1,26 +1,29 @@
const path = require('path'); const path = require('path');
const core = require('@actions/core'); const core = require('@actions/core');
const exec = require('./_exec'); const exec = require('./_exec');
const inputs = require('./inputs.json');
/** /**
* Pre-install plugins * Pre-install plugins
* @returns {Promise<never>} * @returns {Promise<void>}
*/ */
module.exports = async () => { module.exports = async () => {
const extraPlugins = core.getInput('extra_plugins', {required: false}) || ''; const extraPlugins = core.getInput(inputs.extra_plugins);
if (extraPlugins) { if (!extraPlugins) {
const _extraPlugins = extraPlugins return Promise.resolve();
.replace(/['"]/g, '') }
.replace(/[\n\r]/g, ' ');
const {stdout, stderr} = await exec(`npm install ${_extraPlugins}`, { const _extraPlugins = extraPlugins
cwd: path.resolve(__dirname) .replace(/['"]/g, '')
}); .replace(/[\n\r]/g, ' ');
core.debug(stdout);
if (stderr) { const {stdout, stderr} = await exec(`npm install ${_extraPlugins}`, {
return Promise.reject(stderr); cwd: path.resolve(__dirname)
} });
core.debug(stdout);
if (stderr) {
return Promise.reject(stderr);
} }
}; };