# Node.js
|
# Build a general Node.js application with npm.
|
# Add steps that analyze code, save build artifacts, deploy, and more:
|
# https://docs.microsoft.com/vsts/pipelines/languages/javascript
|
# demo: https://github.com/parcel-bundler/parcel/blob/master/azure-pipelines-template.yml
|
|
jobs:
|
- job: {% raw %}${{ parameters.name }}{% endraw %}
|
pool:
|
vmImage: {% raw %}${{ parameters.vmImage }}{% endraw %}
|
strategy:
|
matrix:
|
{%- for version in versions %}
|
node_{{version | replace('.', '_')}}:
|
node_version: {{version}}
|
{%- endfor %}
|
maxParallel: {{versions.length}}
|
steps:
|
- task: NodeTool@0
|
inputs:
|
versionSpec: $(node_version)
|
displayName: 'Install Node.js'
|
{% raw %}
|
# Set ENV
|
- ${{ if ne(parameters.name, 'windows') }}:
|
- script: |
|
echo $PWD
|
export PATH="$PATH:$PWD/node_modules/.bin"
|
echo "##vso[task.setvariable variable=PATH]$PATH"
|
displayName: Set ENV
|
- ${{ if eq(parameters.name, 'windows') }}:
|
- script: |
|
echo %cd%
|
set PATH=%PATH%;%cd%\node_modules\.bin
|
echo "##vso[task.setvariable variable=PATH]%PATH%"
|
displayName: Set ENV
|
{% endraw %}
|
- script: |
|
{%- if npminstall %}
|
npm i npminstall && npminstall
|
{%- else %}
|
npm i
|
{%- endif %}
|
displayName: 'Install Packages'
|
- script: |
|
npm run {{command['azure-pipelines']}}
|
displayName: 'Build & Unit Test'
|
- {% raw %}${{ if ne(parameters.name, 'windows') }}:{% endraw %}
|
- script: |
|
{%- if npminstall %}
|
npminstall codecov && codecov
|
{%- else %}
|
npm i codecov && codecov
|
{%- endif %}
|
displayName: 'Report Coverage'
|