MCPcopy Create free account
hub / github.com/webpack/webpack-cli / #getInfoOutput

Method #getInfoOutput

packages/webpack-cli/src/webpack-cli.ts:1840–1905  ·  view source on GitHub ↗
(options: {
    output?: string;
    additionalPackage?: string[];
    information?: EnvinfoConfig;
  })

Source from the content-addressed store, hash-verified

1838 }
1839
1840 async #getInfoOutput(options: {
1841 output?: string;
1842 additionalPackage?: string[];
1843 information?: EnvinfoConfig;
1844 }): Promise<string> {
1845 let { output } = options;
1846 const envinfoConfig: EnvinfoOptions = {};
1847
1848 if (output) {
1849 // Remove quotes if exist
1850 output = output.replaceAll(/['"]+/g, "");
1851
1852 switch (output) {
1853 case "markdown":
1854 envinfoConfig.markdown = true;
1855 break;
1856 case "json":
1857 envinfoConfig.json = true;
1858 break;
1859 default:
1860 this.logger.error(`'${output}' is not a valid value for output`);
1861 process.exit(2);
1862 }
1863 }
1864
1865 let envinfoOptions: EnvinfoConfig;
1866
1867 if (options.information) {
1868 envinfoOptions = options.information;
1869 } else {
1870 const defaultInformation: EnvinfoConfig = {
1871 Binaries: ["Node", "Yarn", "npm", "pnpm"],
1872 Browsers: [
1873 "Brave Browser",
1874 "Chrome",
1875 "Chrome Canary",
1876 "Edge",
1877 "Firefox",
1878 "Firefox Developer Edition",
1879 "Firefox Nightly",
1880 "Internet Explorer",
1881 "Safari",
1882 "Safari Technology Preview",
1883 ],
1884 // @ts-expect-error No in types
1885 Monorepos: ["Yarn Workspaces", "Lerna"],
1886 System: ["OS", "CPU", "Memory"],
1887 npmGlobalPackages: ["webpack", "webpack-cli", "webpack-dev-server"],
1888 };
1889
1890 const npmPackages = [...DEFAULT_WEBPACK_PACKAGES, ...(options.additionalPackage || [])];
1891
1892 defaultInformation.npmPackages = `{${npmPackages.map((item) => `*${item}*`).join(",")}}`;
1893
1894 envinfoOptions = defaultInformation;
1895 }
1896
1897 const envinfo = (await import("envinfo")).default;

Callers 2

#renderVersionMethod · 0.95
WebpackCLIClass · 0.95

Calls 1

runMethod · 0.80

Tested by

no test coverage detected