# publishes a package to NPM (passed in as $(pkg) variable)

trigger:
- master 

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '12.x'
  displayName: 'Install Node.js'

- script: |
    # ensure latest npm is installed
    npm install -g npm 
    npm config set //registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)

    # grab the file specified
    wget $(pkg)
    rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi 

    # publish it to npm 
    for file in *.tgz 
    do
      npm publish $file --tag latest --access public
      rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
    done


    


# publishes a package to NPM (passed in as $(pkg) variable)
# you can also customize the tag used for NPM with the $(tag) variable (defaults to 'latest')

trigger:
- master 

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '12.x'
  displayName: 'Install Node.js'

- script: |
    # ensure latest npm is installed
    npm install -g npm 
    npm config set //registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)

    # grab the file specified
    wget $(pkg)
    rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi

    # determine the tag
    npmTag = "latest"
    if [ -n "$(tag)" ]; then
      npmTag = $(tag)
    fi

    # publish it to npm 
    for file in *.tgz 
    do
      npm publish $file --tag $npmTag --access public
      rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
    done


    


Use 'tag' parameter for NPM publishing pipeline
Use 'tag' parameter for NPM publishing pipeline
