Skip to content

Commit

Permalink
chore(run): show verbose log output when verbose option is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj committed Sep 8, 2022
1 parent d51987f commit 96a6bf1
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 5 deletions.
99 changes: 99 additions & 0 deletions core/command/__tests__/command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,103 @@ describe("core-command", () => {
);
});
});

describe("loglevel with verbose option true", () => {
it("should be set to verbose if loglevel is error", async () => {
const command = testFactory({
loglevel: "error",
verbose: true,
});
await command;

expect(command.options.loglevel).toEqual("verbose");
});

it("should be set to verbose if loglevel is warn", async () => {
const command = testFactory({
loglevel: "warn",
verbose: true,
});
await command;

expect(command.options.loglevel).toEqual("verbose");
});

it("should be set to verbose if loglevel is info", async () => {
const command = testFactory({
loglevel: "info",
verbose: true,
});
await command;

expect(command.options.loglevel).toEqual("verbose");
});

it("should remain set to verbose if loglevel is verbose", async () => {
const command = testFactory({
loglevel: "verbose",
verbose: true,
});
await command;

expect(command.options.loglevel).toEqual("verbose");
});

it("should not be set to verbose if loglevel is silly", async () => {
const command = testFactory({
loglevel: "silly",
verbose: true,
});
await command;

expect(command.options.loglevel).toEqual("silly");
});
});

describe("loglevel without verbose option", () => {
it("should remain set to error if loglevel is error", async () => {
const command = testFactory({
loglevel: "error",
});
await command;

expect(command.options.loglevel).toEqual("error");
});

it("should remain set to warn if loglevel is warn", async () => {
const command = testFactory({
loglevel: "warn",
});
await command;

expect(command.options.loglevel).toEqual("warn");
});

it("should remain set to info if loglevel is info", async () => {
const command = testFactory({
loglevel: "info",
});
await command;

expect(command.options.loglevel).toEqual("info");
});

it("should remain set to verbose if loglevel is verbose", async () => {
const command = testFactory({
loglevel: "verbose",
});
await command;

expect(command.options.loglevel).toEqual("verbose");
});

it("should remain set to silly if loglevel is silly", async () => {
const command = testFactory({
loglevel: "silly",
});
await command;

expect(command.options.loglevel).toEqual("silly");
});
});
});
6 changes: 5 additions & 1 deletion core/command/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ class Command {
// Environmental defaults prepared in previous step
this.envDefaults
);

if (this.options.verbose && this.options.loglevel !== "silly") {
this.options.loglevel = "verbose";
}
}

configureProperties() {
Expand All @@ -187,7 +191,7 @@ class Command {
}

configureLogging() {
const { loglevel } = this.options;
const { loglevel, verbose } = this.options;

if (loglevel) {
log.level = loglevel;
Expand Down
14 changes: 10 additions & 4 deletions core/lerna/schemas/lerna-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@
"profileLocation": {
"$ref": "#/$defs/commandOptions/shared/profileLocation"
},
"verbose": {
"$ref": "#/$defs/commandOptions/shared/verbose"
},
"skipNxCache": {
"$ref": "#/$defs/commandOptions/run/skipNxCache"
},
Expand Down Expand Up @@ -1395,6 +1398,9 @@
},
"ignorePrepublish": {
"$ref": "#/$defs/commandOptions/shared/ignorePrepublish"
},
"verbose": {
"$ref": "#/$defs/commandOptions/shared/verbose"
}
},
"$defs": {
Expand Down Expand Up @@ -1638,10 +1644,6 @@
"skipNxCache": {
"type": "boolean",
"description": "During `lerna run`, when true, skip the nx cache."
},
"verbose": {
"type": "boolean",
"description": "When useNx is true, show verbose output from dependent tasks."
}
},
"version": {
Expand Down Expand Up @@ -1832,6 +1834,10 @@
"ignorePrepublish": {
"type": "boolean",
"description": "During `lerna publish` and `lerna bootstrap`, when true, disable deprecated 'prepublish' lifecycle script."
},
"verbose": {
"type": "boolean",
"description": "When true, escalates loglevel to 'verbose' and shows nx verbose output if useNx is true."
}
}
}
Expand Down

0 comments on commit 96a6bf1

Please sign in to comment.