Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 77 additions & 95 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"pioppo": "^1.2.1",
"promise-resolve-timeout": "^2.0.1",
"smol-toml": "^1.6.1",
"specialist": "^1.4.5",
"specialist": "^2.0.0",
"tiny-editorconfig": "^1.0.2",
"tiny-readdir": "^2.7.4",
"tiny-readdir-glob": "^1.23.2",
Expand Down
37 changes: 20 additions & 17 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import { bin, color, exit, parseArgv } from "specialist";
import { PRETTIER_VERSION, DEFAULT_PARSERS } from "./constants.js";
import { getPluginOrExit, isBoolean, isNumber, isIntegerInRange, isString } from "./utils.js";
import { normalizeOptions, normalizeFormatOptions, normalizePluginOptions } from "./utils.js";
import type { Bin, PluginsOptions, PrettierPlugin } from "./types.js";
import type { Bin, PluginsOptions } from "./types.js";

const makeBin = (): Bin => {
return (
bin("prettier", "An opinionated code formatter")
const binstance = bin("prettier", "An opinionated code formatter")
/* OPTIONS */
.autoExit(true)
.autoUpdateNotifier(false)
.colors(true)
.package("prettier", PRETTIER_VERSION)
.config({
autoExit: true,
colors: true,
package: "prettier",
version: PRETTIER_VERSION,
})
/* USAGES */
.usage(`${color.cyan("prettier")} ${color.yellow("[file/dir/glob...]")} ${color.green("[options]")}`)
.usage(`${color.cyan("prettier")} ${color.yellow('"src/**/*.js"')} ${color.green("--check")}`)
Expand Down Expand Up @@ -188,15 +189,17 @@ const makeBin = (): Bin => {
section: "Other",
})
/* DEFAULT COMMAND */
.argument("[file/dir/glob...]", "Files, directories or globs to format")
.action(async (options, files) => {
const { run } = await import("./index.js");
const baseOptions = await normalizeOptions(options, files);
const pluginsDefaultOptions = {};
const pluginsCustomOptions = {};
return run(baseOptions, pluginsDefaultOptions, pluginsCustomOptions);
})
);
.argument("[file/dir/glob...]", "Files, directories or globs to format");

binstance.action(async (options, files) => {
const { run } = await import("./index.js");
const baseOptions = await normalizeOptions(options, files);
const pluginsDefaultOptions = {};
const pluginsCustomOptions = {};
return run(baseOptions, pluginsDefaultOptions, pluginsCustomOptions);
});

return binstance;
};

const makePluggableBin = async (): Promise<Bin> => {
Expand Down Expand Up @@ -274,7 +277,7 @@ const makePluggableBin = async (): Promise<Bin> => {
});
}

bin = bin.action(async (options, files) => {
bin.action(async (options, files) => {
const { run } = await import("./index.js");
const baseOptions = await normalizeOptions(options, files);
const pluginsCustomOptions = normalizePluginOptions(options, optionsNames);
Expand Down