First, ensure you have the latest npm
.
To get started with the repo:
$ git clone git@github.com:lerna/lerna.git && cd lerna
$ npm i
Currently, the source is split up into a few categories:
- Utilities: methods to run git, npm, fs, and more.
- Abstractions for packages
- Lerna Commands: each command has an
initialize
andexecute
function.- These commands are consumed as yargs subcommands in src/cli.js, which is called from the executable
bin/lerna.js
.
- These commands are consumed as yargs subcommands in src/cli.js, which is called from the executable
$ npm test
# watch for changes
$ npm run test:watch
# For a specific file (e.g., in test/Command.js)
$ npm run test:watch -- Command.js
By default, npm test
also runs the linter.
You can skip this by calling jest
directly:
$ npx jest
$ npx jest --watch
# etc
$ npm run integration
# watch for changes
$ npm run test:watch-integration
# For a specific file
$ npm run test:watch-integration -- lerna-publish
$ npm run lint
It's also a good idea to hook up your editor to an eslint plugin.
To fix lint errors from the command line:
$ npm run lint -- --fix
If you want to test out Lerna on local repos:
$ npm link
This will set your global lerna
command to the local version.
Note: If the local repo that you are testing in already depends on lerna, you'll need to link your local clone of lerna into the target repo:
# in the target repo
$ npm link lerna
If you would like to check test coverage, run the coverage script, then open
coverage/lcov-report/index.html
in your favorite browser.
$ npm test -- --coverage
# OS X
$ open coverage/lcov-report/index.html
# Linux
$ xdg-open coverage/lcov-report/index.html