node package manager


Cedrus Example Loader


The following commands are available through npm run:

Command Purpose
build Runs code through build process via Angular compiler (ngc)
g Generate code files (see above)
lint Verify code matches linting rules
start Run Webpack's dev-server on project (can be run as npm start)
test Execute unit tests (can be run as npm test <type>)
tagVersion Creates tag for new version and publishes

Unit Testing

Unit testing is done using Karma and Webpack. The setup is all done during the initialize command. The provided testing commands will watch your files for changes.

The two following command is provided by default:

npm test <type>

This command calls the script at tasks/test.js and runs the Karma test runner to execute the tests. Prior to running Karma, the test command looks for a command line argument, if the argument is known, it will run the associated configuration, otherwise it will run the default configuration.


Type Testing TypeScript
default Run through Chrome & PhantomJS with files being watched & tests automatically re-run
headless Run through PhantomJS with files being watched & tests automatically re-run
single Run through PhantomJS one time with no file watching
watch Run through Chrome with files being watched & tests automatically re-run

Note that Chrome still requires a manual refresh on the Debug tab to see updated test results.


Packaging is as simple as publishing to NPM by doing

npm run tagVersion

To test your packages output before publishing, you can run

npm pack

Which will generate a compressed file containing your library as it will look when packaged up and published to NPM. The basic structure of a published library is:


As you can see, the packaging removes any files specific to developing your library.