@@ -129,17 +129,32 @@ func (nc *NpmCommand) SetDisableCVSCheck(disable bool) *NpmCommand {
129129}
130130
131131func (nc * NpmCommand ) Init () error {
132- // Read config file.
133- log .Debug ("Preparing to read the config file" , nc .configFilePath )
134- vConfig , err := project .ReadConfigFile (nc .configFilePath , project .YAML )
135- if err != nil {
136- return err
132+ if nc .configFilePath != "" {
133+ log .Debug ("Preparing to read the config file" , nc .configFilePath )
134+ vConfig , err := project .ReadConfigFile (nc .configFilePath , project .YAML )
135+ if err != nil {
136+ return err
137+ }
138+
139+ repoConfig , err := nc .getRepoConfig (vConfig )
140+ if err != nil {
141+ return err
142+ }
143+ nc .SetRepoConfig (repoConfig )
144+ } else if nc .UseNative () {
145+ // No config file + native mode — CLI layer set useNative and stripped --run-native already.
146+ // Only strip --server-id (not a valid npm flag) and resolve server details.
147+ filteredArgs , serverID , err := coreutils .ExtractServerIdFromCommand (nc .npmArgs )
148+ if err != nil {
149+ return err
150+ }
151+ nc .npmArgs = filteredArgs
152+ nc .serverDetails , err = config .GetSpecificConfig (serverID , true , false )
153+ if err != nil {
154+ return err
155+ }
137156 }
138157
139- repoConfig , err := nc .getRepoConfig (vConfig )
140- if err != nil {
141- return err
142- }
143158 _ , _ , _ , filteredNpmArgs , buildConfiguration , err := commandUtils .ExtractNpmOptionsFromArgs (nc .npmArgs )
144159 if err != nil {
145160 return err
@@ -149,7 +164,7 @@ func (nc *NpmCommand) Init() error {
149164 if err != nil {
150165 return err
151166 }
152- nc .SetRepoConfig ( repoConfig ). SetArgs (filteredNpmArgs ).SetBuildConfiguration (buildConfiguration )
167+ nc .SetArgs (filteredNpmArgs ).SetBuildConfiguration (buildConfiguration )
153168 nc .SetDisableCVSCheck (disableCVSCheck )
154169 return nil
155170}
@@ -199,13 +214,6 @@ func (nc *NpmCommand) PreparePrerequisites(repo string) error {
199214 return err
200215 }
201216 log .Debug ("Working directory set to:" , nc .workingDirectory )
202-
203- // Check for native mode (env var or deprecated flag)
204- useNative , _ , err := CheckIsNativeAndFetchFilteredArgs (nc .npmArgs )
205- if err != nil {
206- return err
207- }
208- nc .SetUseNative (useNative )
209217 nc .installHandler = NewNpmInstallStrategy (nc .UseNative (), nc )
210218
211219 return nc .installHandler .PrepareInstallPrerequisites (repo )
0 commit comments