Question
As a developer, which of the following snippets will enable you to run the commands npm ci and npm run build as part of a workflow?
- A. - run: | npm ci npm run build Correct
- B. - shell: npm ci npm run build
- C. - run: | npm ci npm run build shell: nodejs
- D. - run: npm ci npm run build
- E. - shell: | npm ci npm run build
Explanation
The run keyword executes command-line programs, and the literal block indicator (|) lets a single step run several commands, one per line, so npm ci and npm run build both run. The shell keyword only selects the shell that runs the commands, so a step with shell and no run executes nothing. nodejs is not a supported shell value (bash, pwsh, python, sh, cmd and powershell are), so the snippet that sets shell: nodejs fails. Without the |, the YAML folds the lines into a single command, npm ci npm run build, instead of running two commands.