react/scripts/release/publish-commands/parse-params.js

59 lines
1.2 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
'use strict';
const commandLineArgs = require('command-line-args');
const {splitCommaParams} = require('../utils');
const paramDefinitions = [
{
name: 'dry',
type: Boolean,
description: 'Dry run command without actually publishing to NPM.',
defaultValue: false,
},
{
name: 'tags',
type: String,
multiple: true,
description: 'NPM tags to point to the new release.',
2020-08-01 03:47:28 +08:00
defaultValue: ['untagged'],
},
{
name: 'skipPackages',
type: String,
multiple: true,
description: 'Packages to exclude from publishing',
defaultValue: [],
},
{
name: 'ci',
type: Boolean,
description: 'Run in automated environment, without interactive prompts.',
defaultValue: false,
},
];
module.exports = () => {
const params = commandLineArgs(paramDefinitions);
splitCommaParams(params.skipPackages);
splitCommaParams(params.tags);
2020-08-01 03:47:28 +08:00
params.tags.forEach(tag => {
switch (tag) {
case 'latest':
case 'next':
case 'experimental':
2021-06-08 23:31:42 +08:00
case 'alpha':
case 'beta':
case 'rc':
2020-08-01 03:47:28 +08:00
case 'untagged':
break;
default:
console.error('Unsupported tag: "' + tag + '"');
2020-08-01 03:47:28 +08:00
process.exit(1);
break;
}
});
return params;
};