mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
a04e53df2a
This change extends the npmExecuteScripts step to support execution of npm scripts for specific modules. Previously, it was not possible to execute npm scripts only for specific modules. Now, if the parameter buildDesriptorList is set the scripts defined by the runScripts parameter will be executed for the modules defined by buildDescriptorList. Note, in this case the buildDescriptorExcludeList will be ignored.
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"github.com/SAP/jenkins-library/pkg/log"
|
|
"github.com/SAP/jenkins-library/pkg/npm"
|
|
"github.com/SAP/jenkins-library/pkg/telemetry"
|
|
)
|
|
|
|
func npmExecuteScripts(config npmExecuteScriptsOptions, telemetryData *telemetry.CustomData) {
|
|
npmExecutorOptions := npm.ExecutorOptions{DefaultNpmRegistry: config.DefaultNpmRegistry}
|
|
npmExecutor := npm.NewExecutor(npmExecutorOptions)
|
|
|
|
err := runNpmExecuteScripts(npmExecutor, &config)
|
|
if err != nil {
|
|
log.Entry().WithError(err).Fatal("step execution failed")
|
|
}
|
|
}
|
|
|
|
func runNpmExecuteScripts(npmExecutor npm.Executor, config *npmExecuteScriptsOptions) error {
|
|
if config.Install {
|
|
packageJSONFiles, err := npmExecutor.FindPackageJSONFilesWithExcludes(config.BuildDescriptorExcludeList)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = npmExecutor.InstallAllDependencies(packageJSONFiles)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return npmExecutor.RunScriptsInAllPackages(config.RunScripts, nil, config.ScriptOptions, config.VirtualFrameBuffer, config.BuildDescriptorExcludeList, config.BuildDescriptorList)
|
|
}
|