mirror of
https://github.com/github/codeql-action.git
synced 2025-12-26 09:10:07 +08:00
* Bump @ava/typescript from 3.0.1 to 4.0.0 Bumps [@ava/typescript](https://github.com/avajs/typescript) from 3.0.1 to 4.0.0. - [Release notes](https://github.com/avajs/typescript/releases) - [Commits](https://github.com/avajs/typescript/compare/v3.0.1...v4.0.0) --- updated-dependencies: - dependency-name: "@ava/typescript" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions@github.com>
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
const aliases = ['stdin', 'stdout', 'stderr'];
|
|
|
|
const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
|
|
|
|
export const normalizeStdio = options => {
|
|
if (!options) {
|
|
return;
|
|
}
|
|
|
|
const {stdio} = options;
|
|
|
|
if (stdio === undefined) {
|
|
return aliases.map(alias => options[alias]);
|
|
}
|
|
|
|
if (hasAlias(options)) {
|
|
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
|
|
}
|
|
|
|
if (typeof stdio === 'string') {
|
|
return stdio;
|
|
}
|
|
|
|
if (!Array.isArray(stdio)) {
|
|
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
|
|
}
|
|
|
|
const length = Math.max(stdio.length, aliases.length);
|
|
return Array.from({length}, (value, index) => stdio[index]);
|
|
};
|
|
|
|
// `ipc` is pushed unless it is already present
|
|
export const normalizeStdioNode = options => {
|
|
const stdio = normalizeStdio(options);
|
|
|
|
if (stdio === 'ipc') {
|
|
return 'ipc';
|
|
}
|
|
|
|
if (stdio === undefined || typeof stdio === 'string') {
|
|
return [stdio, stdio, stdio, 'ipc'];
|
|
}
|
|
|
|
if (stdio.includes('ipc')) {
|
|
return stdio;
|
|
}
|
|
|
|
return [...stdio, 'ipc'];
|
|
};
|