diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d06e538..3073c94 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,5 +15,25 @@ steps: versionSpec: '10.x' displayName: 'Install Node.js' -- pwsh: ./build.ps1 - displayName: 'Build script' \ No newline at end of file +- pwsh: ./build.ps1 -Pack -Test + displayName: 'Build script' + +- task: CopyFiles@2 + inputs: + sourceFolder: '$(Build.SourcesDirectory)' + contents: '*.tgz' + targetFolder: $(Build.ArtifactStagingDirectory)/npm + displayName: 'Copy npm package' + +- task: CopyFiles@2 + inputs: + sourceFolder: '$(Build.SourcesDirectory)' + contents: 'package.json' + targetFolder: $(Build.ArtifactStagingDirectory)/npm + displayName: 'Copy package.json' + +- task: PublishBuildArtifacts@1 + inputs: + pathtoPublish: '$(Build.ArtifactStagingDirectory)/npm' + artifactName: npm + displayName: 'Publish npm artifact' diff --git a/build.ps1 b/build.ps1 index 638a25b..a4e15da 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,4 +1,14 @@ param( + # Determines if we run `npm pack`. + [Parameter()] + [switch] + $Pack, + + # Determines if we run the tests. + [Parameter()] + [switch] + $Test, + # Runs the watch npm command instead. [Parameter()] [switch] @@ -13,6 +23,15 @@ npm install if ($Watch.IsPresent) { npm run watch + return } else { npm run compile } + +if ($Test.IsPresent) { + # We would run the tests here. +} + +if ($Pack.IsPresent) { + npm pack +}