'use strict';

var cliCommon = require('@backstage/cli-common');

const runMkdocsServer = (options) => {
  const port = options.port ?? "8000";
  const useDocker = options.useDocker ?? true;
  const dockerImage = options.dockerImage ?? "spotify/techdocs";
  if (useDocker) {
    return cliCommon.run(
      [
        "docker",
        "run",
        "--rm",
        "-w",
        "/content",
        "-v",
        `${process.cwd()}:/content`,
        "-p",
        `${port}:${port}`,
        "-it",
        ...options.dockerEntrypoint ? ["--entrypoint", options.dockerEntrypoint] : [],
        ...options.dockerOptions || [],
        dockerImage,
        "serve",
        "--dev-addr",
        `0.0.0.0:${port}`,
        ...options.mkdocsConfigFileName ? ["--config-file", options.mkdocsConfigFileName] : [],
        ...options.mkdocsParameterClean ? ["--clean"] : [],
        ...options.mkdocsParameterDirtyReload ? ["--dirtyreload"] : [],
        ...options.mkdocsParameterStrict ? ["--strict"] : []
      ],
      {
        onStdout: options.onStdout,
        onStderr: options.onStderr
      }
    );
  }
  return cliCommon.run(
    [
      "mkdocs",
      "serve",
      "--dev-addr",
      `127.0.0.1:${port}`,
      ...options.mkdocsConfigFileName ? ["--config-file", options.mkdocsConfigFileName] : [],
      ...options.mkdocsParameterClean ? ["--clean"] : [],
      ...options.mkdocsParameterDirtyReload ? ["--dirtyreload"] : [],
      ...options.mkdocsParameterStrict ? ["--strict"] : []
    ],
    {
      onStdout: options.onStdout,
      onStderr: options.onStderr
    }
  );
};

exports.runMkdocsServer = runMkdocsServer;
//# sourceMappingURL=mkdocsServer.cjs.js.map
