@@ -5,16 +5,17 @@ import { bin, color, exit, parseArgv } from "specialist";
55import { PRETTIER_VERSION , DEFAULT_PARSERS } from "./constants.js" ;
66import { getPluginOrExit , isBoolean , isNumber , isIntegerInRange , isString } from "./utils.js" ;
77import { normalizeOptions , normalizeFormatOptions , normalizePluginOptions } from "./utils.js" ;
8- import type { Bin , PluginsOptions , PrettierPlugin } from "./types.js" ;
8+ import type { Bin , PluginsOptions } from "./types.js" ;
99
1010const makeBin = ( ) : Bin => {
11- return (
12- bin ( "prettier" , "An opinionated code formatter" )
11+ const binstance = bin ( "prettier" , "An opinionated code formatter" )
1312 /* OPTIONS */
14- . autoExit ( true )
15- . autoUpdateNotifier ( false )
16- . colors ( true )
17- . package ( "prettier" , PRETTIER_VERSION )
13+ . config ( {
14+ autoExit : true ,
15+ colors : true ,
16+ package : "prettier" ,
17+ version : PRETTIER_VERSION ,
18+ } )
1819 /* USAGES */
1920 . usage ( `${ color . cyan ( "prettier" ) } ${ color . yellow ( "[file/dir/glob...]" ) } ${ color . green ( "[options]" ) } ` )
2021 . usage ( `${ color . cyan ( "prettier" ) } ${ color . yellow ( '"src/**/*.js"' ) } ${ color . green ( "--check" ) } ` )
@@ -188,15 +189,17 @@ const makeBin = (): Bin => {
188189 section : "Other" ,
189190 } )
190191 /* DEFAULT COMMAND */
191- . argument ( "[file/dir/glob...]" , "Files, directories or globs to format" )
192- . action ( async ( options , files ) => {
193- const { run } = await import ( "./index.js" ) ;
194- const baseOptions = await normalizeOptions ( options , files ) ;
195- const pluginsDefaultOptions = { } ;
196- const pluginsCustomOptions = { } ;
197- return run ( baseOptions , pluginsDefaultOptions , pluginsCustomOptions ) ;
198- } )
199- ) ;
192+ . argument ( "[file/dir/glob...]" , "Files, directories or globs to format" ) ;
193+
194+ binstance . action ( async ( options , files ) => {
195+ const { run } = await import ( "./index.js" ) ;
196+ const baseOptions = await normalizeOptions ( options , files ) ;
197+ const pluginsDefaultOptions = { } ;
198+ const pluginsCustomOptions = { } ;
199+ return run ( baseOptions , pluginsDefaultOptions , pluginsCustomOptions ) ;
200+ } ) ;
201+
202+ return binstance ;
200203} ;
201204
202205const makePluggableBin = async ( ) : Promise < Bin > => {
@@ -274,7 +277,7 @@ const makePluggableBin = async (): Promise<Bin> => {
274277 } ) ;
275278 }
276279
277- bin = bin . action ( async ( options , files ) => {
280+ bin . action ( async ( options , files ) => {
278281 const { run } = await import ( "./index.js" ) ;
279282 const baseOptions = await normalizeOptions ( options , files ) ;
280283 const pluginsCustomOptions = normalizePluginOptions ( options , optionsNames ) ;
0 commit comments