Skip to content

Latest commit

 

History

History
33 lines (18 loc) · 1.72 KB

authoring-npm-modules.md

File metadata and controls

33 lines (18 loc) · 1.72 KB

Authoring, Testing, and Publishing npm Modules

Whenever possible, we should write JavaScript as small modules that can be published to npm. This document includes guidelines for authoring and publishing these modules.

If you are looking for guidelines on using Node modules, see using-npm-modules-in-projects.md.

The full list of CFPB published node modules is availble on npm.

Authoring

npm published modules should consist of tiny, reusable components. A general guideline is that if there is a bit of JavaScript that your app is using more than once, it would probably make a great npm published module. To simplify the process of authoring node modules, we've created a yeoman generator.

To use the generator:

  1. Install it by running: npm install -g generator-node-cfpb
  2. cd into an empty directory, run this command and follow the prompts: yo node-cfpb

Testing

The beauty of tiny modules is that they're easy to test! Traditionally we have used nodeunit to test our modules.

Publishing

Before publishing your module, read through the npm docs on how to publish a package. When publishing a package to be used in CFPB projects, we ask that you do the following:

  • Make sure the project is hosted in a CFPB github repo
  • Publish the project to npm using your personal account
  • Add the CFPB and at least one colleague as a collaborator on the project.

Aditional Reading