diff options
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r-- | packages/monorepo-scripts/src/publish.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index af707ca47..6e2f1c3b8 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -193,11 +193,11 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (shouldPrintOutput) { utils.log(output); } - const isVersionPrompt = _.includes(output, 'Select a new version'); + const isVersionPrompt = /^\? Select a new version .* (currently .*)$/.test(output); if (isVersionPrompt) { const outputStripLeft = output.split('new version for ')[1]; packageName = outputStripLeft.split(' ')[0]; - child.stdin.write(`${SemVerIndex.Custom}\n`); + sleepAndWrite(child.stdin, SemVerIndex.Custom); } const isCustomVersionPrompt = output === '? Enter a custom version '; if (isCustomVersionPrompt) { @@ -205,11 +205,11 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (_.isUndefined(versionChange)) { throw new Error(`Must have a nextVersion for each packageName. Didn't find one for ${packageName}`); } - child.stdin.write(`${versionChange}\n`); + sleepAndWrite(child.stdin, versionChange); } const isFinalPrompt = _.includes(output, 'Are you sure you want to publish the above changes?'); if (isFinalPrompt && !IS_DRY_RUN) { - child.stdin.write(`y\n`); + sleepAndWrite(child.stdin, 'y'); // After confirmations, we want to print the output to watch the `lerna publish` command shouldPrintOutput = true; } else if (isFinalPrompt && IS_DRY_RUN) { @@ -224,6 +224,13 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string }); } +function sleepAndWrite(fileDescriptor: any, input: string | number): void { + const TIMEOUT = 100; + setTimeout(() => { + fileDescriptor.write(`${input}\n`); + }, TIMEOUT); +} + function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { const updatedVersionIfValid = semver.inc(currentVersion, 'patch'); if (_.isNull(updatedVersionIfValid)) { |