Skip to content

Commit

Permalink
Merge pull request #12 from wings-software/node-build
Browse files Browse the repository at this point in the history
node build command
  • Loading branch information
shaurya-harness authored Dec 21, 2023
2 parents a9e2f45 + 25607be commit 9fc95f7
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions builder/rules/harness/rule_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ConfigureNode(fsys fs.FS, pipeline *spec.Pipeline) error {

// add the npm install step
stage.Steps = append(stage.Steps, utils.CreateScriptStep(image,
"npm_install",
"install dependencies",
"npm install",
))

Expand All @@ -42,53 +42,61 @@ func ConfigureNode(fsys fs.FS, pipeline *spec.Pipeline) error {
// add test with junit for xml reports otherwise add well known test step
if _, ok := json.Scripts["test:junit"]; ok {
stage.Steps = append(stage.Steps, utils.CreateScriptStepWithReports(image,
"npm_test_reports",
"test_reports",
"npm run test:junit",
))
} else if _, ok := json.Scripts["test"]; ok {
stage.Steps = append(stage.Steps, utils.CreateScriptStep(image,
"npm_test",
"test",
"npm run test",
))
}

// add well-known jest coverage command
if _, ok := json.Scripts["coverage"]; ok {
stage.Steps = append(stage.Steps, utils.CreateScriptStep(image,
"npm_coverage",
"coverage",
"npm run coverage",
))
}

// add well-known lint command
if _, ok := json.Scripts["lint"]; ok {
stage.Steps = append(stage.Steps, utils.CreateScriptStep(image,
"npm_lint",
"lint",
"npm run lint",
))
}

// add well-known e2e command
if _, ok := json.Scripts["e2e"]; ok {
stage.Steps = append(stage.Steps, utils.CreateScriptStep(image,
"npm_e2e",
"e2e",
"npm run e2e",
))
}

// add well-known e2e docker if infra is cloud
if _, ok := json.Scripts["e2e:docker"]; ok && image == "" {
// add well-known dist command
if _, ok := json.Scripts["dist"]; ok {
stage.Steps = append(stage.Steps, utils.CreateScriptStep(image,
"npm_e2e_docker",
"npm run e2e docker",
"dist",
"npm run dist",
))
}

// add well-known dist command
if _, ok := json.Scripts["dist"]; ok {
// add well-known build command
if _, ok := json.Scripts["build"]; ok {
stage.Steps = append(stage.Steps, utils.CreateScriptStep(image,
"npm_dist",
"npm run dist",
"build",
"npm run build",
))
}

// add well-known e2e docker if infra is cloud
if _, ok := json.Scripts["e2e:docker"]; ok && image == "" {
stage.Steps = append(stage.Steps, utils.CreateScriptStep(image,
"e2e_docker",
"npm run e2e docker",
))
}

Expand Down

0 comments on commit 9fc95f7

Please sign in to comment.