SVG.js

Contributing

We love contributions. Yes indeed, we used the word LOVE! But please make sure you follow the same coding style. Here are some guidelines.

Building

After contributing you probably want to build the library to run some specs. Make sure you have Node.js installed on your system, cd to the svg.js directory and run:

$ npm install

Build SVG.js by running rollup:

$ npm run build

The resulting files can be found in the dist folder.

Testing

There is two ways to run the test suite. One is from the command line and the other is in your browser.
To run the test suite at the command line, you need to have Firefox installed.

$ npm test

To run the test suite in your default browser, simply open /spec/SpecRunner.html. Usually by double click.

If you are the cautious type, you might want to read, before you push, on how to prevent pushing failing commits.

Before you push

Imagine that you're tweaking some part of svg.js and as the responsible person you are, you made sure to run npm test before pushing. Unfortunately npm test tests the current dist/svg.js which only has your edits if you first did npm run build.

This has happened to me a couple of times and as a svg.js contributor, it's embarrassing.

Fortunately git has a pre-push hook which can save yourself from the embarrassment.

I have created a pre-push hook that will build a new dist/svg.js and run the tests. It's developed on Ubuntu 16.04 but should work on all *nix platforms. You can disable this check with:

git push --no-verify

pre-push

#!/bin/sh

npm run build:test && npm run test:quick

# check how the test went
testCode=$?
[ "$testCode" = 0 ] || echo "Your current build does not pass our unit tests - please make them pass before you push"
# revert artifacts created during build
git reset --hard $(git log -1 --pretty=%H)
# exit with the test exit code
exit $testCode

Install

Put pre-push in your local SVG.js repository, in the .git/hooks folder and make it executable:

sudo chmod +x .git/hooks/pre-push

To disable the check when you push, write:

git push --no-verify
Fork me on GitHub