From f905bafe82eb2f7b15d2bfa6cd4b3fec00b5aa51 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Wed, 5 Jul 2017 15:35:50 +0300 Subject: [PATCH 1/2] Fix plugins prompts on postinstall In case some plugins (like `nativescript-plugin-firebase`) try to prompt the user on postinstall, users are unable to answer the question when `tns plugin add ` is used. The reason is that the stdin of current process is not passed to the stdin of the `npm install` process and the user has no way to input the result. Fix this by using "inherit" of current stdio when the console is interactive. --- lib/node-package-manager.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/node-package-manager.ts b/lib/node-package-manager.ts index c64f2c8236..8289e66baa 100644 --- a/lib/node-package-manager.ts +++ b/lib/node-package-manager.ts @@ -1,5 +1,6 @@ import * as path from "path"; import { exported } from "./common/decorators"; +import { isInteractive } from "./common/helpers"; export class NodePackageManager implements INodePackageManager { private static SCOPED_DEPENDENCY_REGEXP = /^(@.+?)(?:@(.+?))?$/; @@ -194,16 +195,20 @@ export class NodePackageManager implements INodePackageManager { private async getNpmInstallResult(params: string[], cwd: string): Promise { return new Promise((resolve, reject) => { const npmExecutable = this.getNpmExecutableName(); - let childProcess = this.$childProcess.spawn(npmExecutable, params, { cwd, stdio: "pipe" }); + const stdioValue = isInteractive() ? "inherit" : "pipe"; + + const childProcess = this.$childProcess.spawn(npmExecutable, params, { cwd, stdio: stdioValue }); let isFulfilled = false; let capturedOut = ""; let capturedErr = ""; - childProcess.stdout.on("data", (data: string) => { - this.$logger.write(data.toString()); - capturedOut += data; - }); + if (childProcess.stdout) { + childProcess.stdout.on("data", (data: string) => { + this.$logger.write(data.toString()); + capturedOut += data; + }); + } if (childProcess.stderr) { childProcess.stderr.on("data", (data: string) => { From 6573c886f6b0526e62f91db80ce75f9835562941 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Wed, 5 Jul 2017 16:01:09 +0300 Subject: [PATCH 2/2] Update CHANGELOG for 3.1.2 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d88b73194..3b014a88ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ NativeScript CLI Changelog ================ + +3.1.2 (2017, July 06) +== + +### Fixed +* [Fixed #2950](https://github.com/NativeScript/nativescript-cli/issues/2950): Unable to provide user input on postinstall of plugin + 3.1.1 (2017, June 28) ==