@@ -6,11 +6,12 @@ import { ESLint } from "eslint";
6
6
import fs from "fs-extra" ;
7
7
8
8
import { ACTIVATION , impSortGlob } from "@/config" ;
9
- import { loadConfigModule , loggerInfo , printError , printInfo } from "@/helper" ;
9
+ import { loggerInfo , printError , printInfo } from "@/helper" ;
10
10
import { ImpSortOptions } from "@/types" ;
11
11
12
- const mergeConfig = async ( ) => {
13
- const config = await loadConfigModule ( ) ;
12
+ import { CodeGeniusOptions } from "./../types" ;
13
+
14
+ const mergeConfig = async ( config : CodeGeniusOptions ) => {
14
15
const commands = config && config ?. commands ;
15
16
if ( commands && commands . impsort ) {
16
17
const { paths } = commands . impsort ;
@@ -23,7 +24,9 @@ const mergeConfig = async () => {
23
24
} ;
24
25
} ;
25
26
26
- const generateEnquirer = async ( ) : Promise < ImpSortOptions > => {
27
+ const generateEnquirer = async (
28
+ config : CodeGeniusOptions ,
29
+ ) : Promise < ImpSortOptions > => {
27
30
const files = fs
28
31
. readdirSync ( path . join ( process . cwd ( ) , "." ) )
29
32
. filter ( ( v ) => ! v . startsWith ( "." ) )
@@ -34,7 +37,7 @@ const generateEnquirer = async (): Promise<ImpSortOptions> => {
34
37
} ;
35
38
} ) ;
36
39
files . sort ( ( v1 , v2 ) => v1 . sort - v2 . sort ) ;
37
- const { paths } = await mergeConfig ( ) ;
40
+ const { paths } = await mergeConfig ( config ) ;
38
41
const fileMultiChoices = files . map ( ( v ) => {
39
42
return {
40
43
name : `./${ v . file } ` ,
@@ -82,7 +85,7 @@ export const impSort = async (paths: string[]) => {
82
85
}
83
86
} ;
84
87
85
- export default function impSortInstaller ( cli : CAC ) {
88
+ export default function impSortInstaller ( cli : CAC , config : CodeGeniusOptions ) {
86
89
return {
87
90
name : "impSortInstaller" ,
88
91
setup : ( ) => {
@@ -93,7 +96,7 @@ export default function impSortInstaller(cli: CAC) {
93
96
const { pattern } = options ;
94
97
let paths = [ ] ;
95
98
if ( ! pattern ) {
96
- const result = await generateEnquirer ( ) ;
99
+ const result = await generateEnquirer ( config ) ;
97
100
paths = result . files ;
98
101
} else {
99
102
paths =
0 commit comments