Skip to content

Commit

Permalink
Fixup: Adding check for exactly one file back in
Browse files Browse the repository at this point in the history
  • Loading branch information
platinumazure committed Sep 23, 2016
1 parent b242031 commit 64db3df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/cli.js
Expand Up @@ -138,7 +138,10 @@ const cli = {
log.info("v" + require("../package.json").version);

} else if (currentOptions.printConfig) {
if (text) {
if (files.length) {
log.error("The --print-config option must be used with exactly one file name.");
return 1;
} else if (text) {
log.error("The --print-config option is not available for piped-in code.");
return 1;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/cli.js
Expand Up @@ -880,6 +880,17 @@ describe("cli", function() {
assert.equal(exitCode, 0);
});

it("should error if any positional file arguments are passed", function() {
const filePath1 = getFixturePath("files", "bar.js");
const filePath2 = getFixturePath("files", "foo.js");

const exitCode = cli.execute("--print-config " + filePath1 + " " + filePath2);

assert.isTrue(log.info.notCalled);
assert.isTrue(log.error.calledOnce);
assert.equal(exitCode, 1);
});

it("should error out when executing on text", function() {
const exitCode = cli.execute("--print-config", "foo = bar;");

Expand Down

0 comments on commit 64db3df

Please sign in to comment.