mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
PR #20717 accidentally broke the `--commit` parameter because the script errors if you provide both a `--build` and a `--commit`. I solved by removing the validation error. When there's a conflict, it will choose the --`build`. (Although maybe we should `--build` entirely and always uses `--commit`. I think `--commit` is a sufficient replacement.)
66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
const commandLineArgs = require('command-line-args');
|
|
const getBuildIdForCommit = require('../get-build-id-for-commit');
|
|
|
|
const paramDefinitions = [
|
|
{
|
|
name: 'build',
|
|
type: Number,
|
|
description:
|
|
'Circle CI build identifier (e.g. https://circleci.com/gh/facebook/react/<build>)',
|
|
defaultValue: null,
|
|
},
|
|
{
|
|
name: 'commit',
|
|
type: String,
|
|
description:
|
|
'GitHub commit SHA. When provided, automatically finds corresponding CI build.',
|
|
defaultValue: null,
|
|
},
|
|
{
|
|
name: 'skipTests',
|
|
type: Boolean,
|
|
description: 'Skip automated fixture tests.',
|
|
defaultValue: false,
|
|
},
|
|
{
|
|
name: 'releaseChannel',
|
|
alias: 'r',
|
|
type: String,
|
|
description: 'Release channel (stable or experimental)',
|
|
},
|
|
];
|
|
|
|
module.exports = async () => {
|
|
const params = commandLineArgs(paramDefinitions);
|
|
|
|
if (params.build !== null) {
|
|
// TODO: Should we just remove the `build` param? Seems like `commit` is a
|
|
// sufficient replacement.
|
|
} else {
|
|
if (params.commit === null) {
|
|
console.error('Must provide either `build` or `commit`.');
|
|
process.exit(1);
|
|
}
|
|
try {
|
|
params.build = await getBuildIdForCommit(params.commit);
|
|
} catch (error) {
|
|
console.error(error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
const channel = params.releaseChannel;
|
|
if (channel !== 'experimental' && channel !== 'stable') {
|
|
console.error(
|
|
`Invalid release channel (-r) "${channel}". Must be "stable" or "experimental".`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
return params;
|
|
};
|