Skip to content

Commit

Permalink
Don't ask for usage permission if non-interactive
Browse files Browse the repository at this point in the history
You can run the prototype toolkit in a way that does not accept input.
A basic example would be:

   $ npm start | cat

If this is the first time you have run the prototype kit, the
application will hang as there is no way to respond to the question
about recording usage data. This means it is difficult to run the
prototype kit solely without user input.

This commit changes the behaviour of that prompt to only appear if the
user is running the command in a TTY context.

If the user is not running the prototype kit in a TTY, the prompt will
be skipped and the default action will occur as if the user had simply
hit return. In this case, it'll default to "no" and opt the user out of
usage data collection automatically.

A downside of this approach is that the user will not get asked again
if they subsequently run the kit interactively. However, it is unlikely
that users will wish to run the prototype kit initially within a
pipeline whilst also wishing to run it interactively at a later date.

Closes alphagov#695. Another prompt occurs when the chosen port is in use, but
this commit doesn't attempt to edit that.
  • Loading branch information
zuzak committed Feb 26, 2019
1 parent 44737b7 commit 919e98e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/usage_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ exports.askForUsageDataPermission = function () {
required: true,
type: 'string',
pattern: /y(es)?|no?/i,
message: 'Please enter y or n'
message: 'Please enter y or n',
ask: function () {
return process.stdout.isTTY
}
}], function (err, result) {
if (err) {
reject(err)
Expand Down

0 comments on commit 919e98e

Please sign in to comment.