From d50174b89eda6a9df590dac6b121885b74ec35d9 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 21:33:03 +0200 Subject: Add ignore flag --- packages/monorepo-scripts/src/publish.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'packages/monorepo-scripts/src') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index df1bfff2f..42d0a374f 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -185,7 +185,12 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string }); let shouldPrintOutput = false; let packageName: string; + let ignoreCounter = 0; child.stdout.on('data', (data: Buffer) => { + if (ignoreCounter !== 0) { + ignoreCounter--; + return; // ignore + } const output = data.toString('utf8'); console.log('-------'); console.log(output); @@ -201,6 +206,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string return; // noop } packageName = packageNameFound; + ignoreCounter = 1; // SemVerIndex.Custom is a single digit number sleepAndWrite(child.stdin, SemVerIndex.Custom); } const isCustomVersionPrompt = _.includes(output, 'Enter a custom version'); @@ -209,10 +215,12 @@ 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}`); } + ignoreCounter = versionChange.length; sleepAndWrite(child.stdin, versionChange); } const isFinalPrompt = _.includes(output, 'Are you sure you want to publish the above changes?'); if (isFinalPrompt && !IS_DRY_RUN) { + ignoreCounter = 'y'.length; sleepAndWrite(child.stdin, 'y'); // After confirmations, we want to print the output to watch the `lerna publish` command shouldPrintOutput = true; -- cgit v1.2.3