Skip to content

Commit

Permalink
fix(run:bundleStats): Take path to dangerfile instead of directory (#…
Browse files Browse the repository at this point in the history
…13154)

The dangerfile path had some magic strings in the code, so this change
makes the full path to the dangerfile the argument instead of a folder
containing a dangerfile at a specific place inside it. The default
dangerfile is still used in all known uses, so the real meaningful value
is the default.

BREAKING CHANGE: The `--dirname` argument has been removed. There is now
a `--dangerfile` argument that defaults to the built-in dangerfile but
can be customized if needed.
  • Loading branch information
tylerbutler committed Dec 1, 2022
1 parent f71df24 commit 0372fe0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions build-tools/packages/build-cli/docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Generate a report from input bundle stats collected through the collect bundleSt

```
USAGE
$ flub run bundleStats [-v] [--dirname <value>]
$ flub run bundleStats [-v] [--dangerfile <value>]
FLAGS
-v, --verbose Verbose logging.
--dirname=<value> [default: current directory] Directory containing bundle stats input
-v, --verbose Verbose logging.
--dangerfile=<value> Path to dangerfile
DESCRIPTION
Generate a report from input bundle stats collected through the collect bundleStats command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
*/
import { Flags } from "@oclif/core";
import { execSync } from "child_process";
import path from "path";

import { BaseCommand } from "../../base";

export default class RunBundlestats extends BaseCommand<typeof RunBundlestats.flags> {
static description = `Generate a report from input bundle stats collected through the collect bundleStats command.`;

static flags = {
dirname: Flags.string({
description: "[default: current directory] Directory containing bundle stats input",
dangerfile: Flags.file({
description: "Path to dangerfile",
required: false,
}),
...BaseCommand.flags,
Expand All @@ -21,8 +22,8 @@ export default class RunBundlestats extends BaseCommand<typeof RunBundlestats.fl
public async run(): Promise<void> {
const flags = this.processedFlags;
// eslint-disable-next-line unicorn/prefer-module
const dirname = flags.dirname ?? __dirname;
const dangerfile = flags.dangerfile ?? path.join(__dirname, "../../lib/dangerfile.js");

execSync(`npx danger ci -d ${dirname}/lib/dangerfile.js`, { stdio: "inherit" });
execSync(`npx danger ci -d ${dangerfile}`, { stdio: "inherit" });
}
}

0 comments on commit 0372fe0

Please sign in to comment.