Skip to content

Commit 4ae26d9

Browse files
Show prompt only in interactive mode (#583)
Co-authored-by: Sindre Sorhus <[email protected]>
1 parent 9817261 commit 4ae26d9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"import-local": "^3.0.2",
4747
"inquirer": "^7.3.3",
4848
"is-installed-globally": "^0.3.2",
49+
"is-interactive": "^1.0.0",
4950
"is-scoped": "^2.1.0",
5051
"issue-regex": "^3.1.0",
5152
"listr": "^0.14.3",

source/ui.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const chalk = require('chalk');
44
const githubUrlFromGit = require('github-url-from-git');
55
const {htmlEscape} = require('escape-goat');
66
const isScoped = require('is-scoped');
7+
const isInteractive = require('is-interactive');
78
const util = require('./util');
89
const git = require('./git-util');
910
const {prereleaseTags, checkIgnoreStrategy, getRegistryUrl, isExternalRegistry} = require('./npm/util');
@@ -56,10 +57,16 @@ const checkIgnoredFiles = async pkg => {
5657
return true;
5758
}
5859

60+
const message = `The following new files are not already part of your published package:\n${chalk.reset(ignoredFiles.map(path => `- ${path}`).join('\n'))}`;
61+
if (!isInteractive()) {
62+
console.log(message);
63+
return true;
64+
}
65+
5966
const answers = await inquirer.prompt([{
6067
type: 'confirm',
6168
name: 'confirm',
62-
message: `The following new files are not already part of your published package:\n${chalk.reset(ignoredFiles.map(path => `- ${path}`).join('\n'))}\nContinue?`,
69+
message: `${message}\nContinue?`,
6370
default: false
6471
}]);
6572

0 commit comments

Comments
 (0)