@@ -198,40 +198,40 @@ func (sl *SealightsHook) ExtractNpmRunScriptName(command string) (string, error)
198198 if strings .HasPrefix (cleanCommand , "web:" ) {
199199 cleanCommand = strings .TrimSpace (cleanCommand [4 :])
200200 }
201-
201+
202202 // Handle commands with cd prefix (e.g., "cd app && npm run start")
203203 if strings .Contains (cleanCommand , "&&" ) {
204204 parts := strings .Split (cleanCommand , "&&" )
205205 if len (parts ) >= 2 {
206206 cleanCommand = strings .TrimSpace (parts [len (parts )- 1 ])
207207 }
208208 }
209-
209+
210210 // Extract script name from npm commands
211211 // Patterns to match:
212212 // - "npm start" -> "start"
213213 // - "npm run start-dev" -> "start-dev"
214214 // - "npm run dev" -> "dev"
215215 patterns := []string {
216- `^npm\s+run\s+([a-zA-Z0-9\-_]+)` , // npm run <script>
217- `^npm\s+([a-zA-Z0-9\-_]+)` , // npm <script>
216+ `^npm\s+run\s+([a-zA-Z0-9\-_]+)` , // npm run <script>
217+ `^npm\s+([a-zA-Z0-9\-_]+)` , // npm <script>
218218 }
219-
219+
220220 for _ , pattern := range patterns {
221221 re , err := regexp .Compile (pattern )
222222 if err != nil {
223223 sl .Log .Warning ("Failed to compile regex pattern %s: %s" , pattern , err )
224224 continue
225225 }
226-
226+
227227 matches := re .FindStringSubmatch (cleanCommand )
228228 if len (matches ) >= 2 {
229229 scriptName := matches [1 ]
230230 sl .Log .Debug ("Extracted npm script name: %s from command: %s" , scriptName , command )
231231 return scriptName , nil
232232 }
233233 }
234-
234+
235235 return "" , fmt .Errorf ("failed to extract npm script name from command: %s" , command )
236236}
237237
@@ -240,11 +240,11 @@ func (sl *SealightsHook) ValidateNpmRunScript(packageJson map[string]interface{}
240240 if ! ok || scripts == nil {
241241 return fmt .Errorf ("no scripts section found in package.json" )
242242 }
243-
243+
244244 if _ , exists := scripts [scriptName ]; ! exists {
245245 return fmt .Errorf ("script '%s' not found in package.json" , scriptName )
246246 }
247-
247+
248248 return nil
249249}
250250
@@ -322,7 +322,7 @@ func (sl *SealightsHook) SetApplicationStartInPackageJson(stager *libbuildpack.S
322322 if err != nil {
323323 return err
324324 }
325-
325+
326326 // Validate that the target script exists
327327 err = sl .ValidateNpmRunScript (packageJson , targetScript )
328328 if err != nil {
@@ -338,20 +338,20 @@ func (sl *SealightsHook) SetApplicationStartInPackageJson(stager *libbuildpack.S
338338 return err
339339 }
340340 }
341-
341+
342342 scripts := packageJson ["scripts" ].(map [string ]interface {})
343343 originalStartScript , _ := scripts [targetScript ].(string )
344344 if originalStartScript == "" {
345345 return fmt .Errorf ("failed to read %s script from %s" , targetScript , PackageJsonFile )
346346 }
347-
347+
348348 // Update the command with Sealights injection
349349 var newCmd string
350350 newCmd , err = sl .updateStartCommand (originalStartScript )
351351 if err != nil {
352352 return err
353353 }
354-
354+
355355 sl .Log .Debug ("Injecting Sealights into '%s' script: %s -> %s" , targetScript , originalStartScript , newCmd )
356356 scripts [targetScript ] = newCmd
357357
@@ -529,13 +529,13 @@ func (sl *SealightsHook) injectSealights(stager *libbuildpack.Stager) error {
529529 sl .Log .Info ("Integrating sealights into manifest.yml" )
530530 return sl .SetApplicationStartInManifest (stager )
531531 } else {
532- sl .Log .Info ("Integrating sealights into package.json" )
533- // Use configured script name or default to "start"
534- scriptName := sl .parameters .NpmRunScript
535- if scriptName == "" {
536- scriptName = "start"
537- }
538- return sl .SetApplicationStartInPackageJson (stager , scriptName )
532+ sl .Log .Info ("Integrating sealights into package.json" )
533+ // Use configured script name or default to "start"
534+ scriptName := sl .parameters .NpmRunScript
535+ if scriptName == "" {
536+ scriptName = "start"
537+ }
538+ return sl .SetApplicationStartInPackageJson (stager , scriptName )
539539 }
540540}
541541
0 commit comments