Skip to content

Commit b218580

Browse files
fix: open feedback form on preuninstall
Currently the when the preuninstall step executes CLI's command, it exec's the process without inheriting the stdout. This way CLI always thinks the terminal is not interactive and never opens the feedback form. Replace the exec with spawn and set "inherit" for stdout. This way CLI will determine if the terminal is in interactive mode correctly.
1 parent b419c21 commit b218580

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

preuninstall.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
"use strict";
22

3+
var path = require("path");
34
var child_process = require("child_process");
4-
var commandArgs = ["bin/tns", "dev-preuninstall"];
5+
var commandArgs = [path.join(__dirname, "bin", "tns"), "dev-preuninstall"];
56

6-
var child = child_process.exec("node " + commandArgs.join(" "), function (error) {
7-
if (error) {
8-
// Some npm versions (3.0, 3.5.1, 3.7.3) remove the NativeScript node_modules before the preuninstall script is executed and the script can't find them (the preuninstall script is like postinstall script).
9-
// The issue is described in the npm repository https://github.com/npm/npm/issues/8806 and it is not fixed in version 3.1.1 as commented in the conversation.
10-
console.error("Failed to complete all pre-uninstall steps.");
11-
}
12-
});
7+
var childProcess = child_process.spawn(process.execPath, commandArgs, { stdio: "inherit"})
138

14-
child.stdout.pipe(process.stdout);
9+
childProcess.on("error", (err) => {
10+
console.error(`Failed to complete all pre-uninstall steps. Error is ${err.message}`);
11+
});

0 commit comments

Comments
 (0)