diff --git a/plugins/gh-pages/__tests__/gh-pages.test.ts b/plugins/gh-pages/__tests__/gh-pages.test.ts index 4d83bdb30..150c881a1 100644 --- a/plugins/gh-pages/__tests__/gh-pages.test.ts +++ b/plugins/gh-pages/__tests__/gh-pages.test.ts @@ -130,6 +130,25 @@ describe("Gh-Pages Plugin", () => { expect(execSpy).toHaveBeenCalledWith("npx", [ "push-dir", "--cleanup", + false, + "--remote=undefined", + "--dir=test", + "--branch=gh-pages", + '--message="Update docs [skip ci]"', + ]); + }); + + test("should use verbose logs", async () => { + const logger = dummyLog(); + logger.logLevel = "verbose"; + const hooks = createTest({ dir: "test" }, { logger }); + await hooks.afterRelease.promise({ + response: { data: { prerelease: false } }, + } as any); + expect(execSpy).toHaveBeenCalledWith("npx", [ + "push-dir", + "--cleanup", + "--verbose", "--remote=undefined", "--dir=test", "--branch=gh-pages", diff --git a/plugins/gh-pages/src/index.ts b/plugins/gh-pages/src/index.ts index 4b4d1a249..c76bb8133 100644 --- a/plugins/gh-pages/src/index.ts +++ b/plugins/gh-pages/src/index.ts @@ -7,7 +7,7 @@ import { } from "@auto-it/core"; import { execSync } from "child_process"; import * as t from "io-ts"; -import endent from 'endent'; +import endent from "endent"; const required = t.interface({ /** The directory to push to gh-pages */ @@ -106,9 +106,14 @@ export default class GhPagesPlugin implements IPlugin { } try { + const isVerbose = + auto.logger.logLevel === "verbose" || + auto.logger.logLevel === "veryVerbose"; + await execPromise("npx", [ "push-dir", "--cleanup", + isVerbose && "--verbose", `--remote=${auto.remote}`, `--dir=${this.options.dir}`, `--branch=${this.options.branch}`, @@ -119,7 +124,7 @@ export default class GhPagesPlugin implements IPlugin { "Oh no! It looks like there was trouble publishing to GitHub Pages 😢" ); - if (error.message.includes('git not clean')) { + if (error.message.includes("git not clean")) { auto.logger.log.error(endent` Your repo currently has uncommitted files in it. For the gh-pages plugin to work your git state must be clean. @@ -127,14 +132,14 @@ export default class GhPagesPlugin implements IPlugin { 1. Add the files to your gitignore (ex: your built gh-pages website dist files) 2. Commit the files (ex: Something you want to track in the repo) - `) + `); const status = await execPromise("git", ["status", "--porcelain"]); if (status) { auto.logger.log.error("Uncomitted Changes:\n", status); } - } + } throw error; }