Skip to content

PublishNodeModule Task

Joseph Larionov edited this page Oct 22, 2019 · 6 revisions

Overview

The PublishNodeModule task runs npm publish in the current working directory. We recommend using this task instead of the Npm task because this task handles credentials needed to publish to an NPM repository as securely as possible. Just before it publishes, it base-64 encodes the password, saves it to an .npmrc file in the task working directory (this is what NPM wants/expects). After the build, it removes the file. It also runs the npm version command to update your package's version to the version of the current build (Whiskey 0.43.0 and later), including prerelease information. Use Whiskey's Version task to set prerelease information for your build. When publishing a prerelease version, the task will publish the module with the Whiskey variable WHISKEY_SEMVER2_PRERELEASE_ID (Variables) as the distribution tag.

Use the Tag property (Whiskey 0.43.0 and later) to publish the module with a specific distribution tag.

It also runs npm prune before publishing.

This task will install the latest LTS version of Node into a .node directory (in the same directory as your whiskey.yml file). To use a specific version, set the engines.node property in your package.json file to the version you want. (See https://docs.npmjs.com/files/package.json#engines for more information.)

Properties

  • NpmRegistryUri (mandatory): the URI to the registry where the module should be published.
  • CredentialID (mandatory): the credential to use when publishing. Credentials are added to your build with the Add-WhiskeyCredential function. This CredentialID property should be the same value as the ID parameter used when adding the credential with Add-WhiskeyCredential.
  • EmailAddress (mandatory): the email address to use when publishing.
  • Tag (Added in 0.43.0): the distribution tag to use when publishing the module.

Examples

Example 1

    Build:
    - PublishNodeModule

Demonstrates how to publish the Node module located in the same directory as your whiskey.yml file

Example 2

    Build:
    - PublishNodeModule:
        WorkingDirectory: 'app'

Demonstrates how to publish a Node module that isn't in the same directory as your whiskey.yml file. In this example, the Node module in the app directory is published (app is resolved relative to your whiskey.yml file).

Example 3

    Build:
    - PublishNodeModule:
        Tag: mycutomtag

Demonstrates how to publish the Node module with the distribution tag mycutomtag.

Clone this wiki locally