Skip to content

Commit

Permalink
Show prompt only in interactive mode (#583)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
bunysae and sindresorhus committed Dec 21, 2020
1 parent 9817261 commit 4ae26d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -46,6 +46,7 @@
"import-local": "^3.0.2",
"inquirer": "^7.3.3",
"is-installed-globally": "^0.3.2",
"is-interactive": "^1.0.0",
"is-scoped": "^2.1.0",
"issue-regex": "^3.1.0",
"listr": "^0.14.3",
Expand Down
9 changes: 8 additions & 1 deletion source/ui.js
Expand Up @@ -4,6 +4,7 @@ const chalk = require('chalk');
const githubUrlFromGit = require('github-url-from-git');
const {htmlEscape} = require('escape-goat');
const isScoped = require('is-scoped');
const isInteractive = require('is-interactive');
const util = require('./util');
const git = require('./git-util');
const {prereleaseTags, checkIgnoreStrategy, getRegistryUrl, isExternalRegistry} = require('./npm/util');
Expand Down Expand Up @@ -56,10 +57,16 @@ const checkIgnoredFiles = async pkg => {
return true;
}

const message = `The following new files are not already part of your published package:\n${chalk.reset(ignoredFiles.map(path => `- ${path}`).join('\n'))}`;
if (!isInteractive()) {
console.log(message);
return true;
}

const answers = await inquirer.prompt([{
type: 'confirm',
name: 'confirm',
message: `The following new files are not already part of your published package:\n${chalk.reset(ignoredFiles.map(path => `- ${path}`).join('\n'))}\nContinue?`,
message: `${message}\nContinue?`,
default: false
}]);

Expand Down

0 comments on commit 4ae26d9

Please sign in to comment.