diff --git a/js/README.rst b/js/README.rst
index a68dd9a0..e8782213 100644
--- a/js/README.rst
+++ b/js/README.rst
@@ -36,40 +36,27 @@ Building from source
sudo apt-get update
sudo apt-get install nodejs npm
-2. Assuming you install from PPA, setup your ``NODE_PATH`` environment variable
- to include ``/usr/lib/node_modules``. Add the following to your
- ``~/.bashrc`` or equivalent::
-
- export NODE_PATH=/usr/lib/node_modules:$NODE_PATH
-
-3. Install `Buster.js `_ and `Grunt
- `_ globally (or locally, and make sure you get their
- binaries on your ``PATH``)::
-
- sudo npm -g install buster grunt
-
-4. Install the grunt-buster Grunt plugin locally, when in the ``js/`` dir::
+2. Enter the ``js/`` dir and install development dependencies::
cd js/
- npm install grunt-buster
+ npm install
-5. Install `PhantomJS `_ so that we can run the tests
- without a browser::
+That's it.
- sudo apt-get install phantomjs
+You can now run the tests::
- It is packaged in Ubuntu since 12.04, but I haven't tested with versions
- older than 1.6 which is the one packaged in Ubuntu 12.10.
+ npm test
-6. Run Grunt to lint, test, concatenate, and minify the source::
+To run tests automatically when you save a file::
- grunt
+ npm run-script watch
- The files in ``../mopidy/frontends/http/data/`` should now be up to date.
+To run tests, concatenate, minify the source, and update the JavaScript files
+in ``mopidy/frontends/http/data/``::
+ npm run-script build
-Development tips
-================
+To run other `grunt `_ targets which isn't predefined in
+``package.json`` and thus isn't available through ``npm run-script``::
-If you're coding on the JavaScript library, you should know about ``grunt
-watch``. It lints and tests the code every time you save a file.
+ PATH=./node_modules/.bin:$PATH grunt foo
diff --git a/js/grunt.js b/js/grunt.js
index d835fd77..46afc8af 100644
--- a/js/grunt.js
+++ b/js/grunt.js
@@ -64,7 +64,9 @@ module.exports = function (grunt) {
uglify: {}
});
- grunt.registerTask("default", "lint buster concat min");
+ grunt.registerTask("test", "lint buster");
+ grunt.registerTask("build", "lint buster concat min");
+ grunt.registerTask("default", "build");
grunt.loadNpmTasks("grunt-buster");
};
diff --git a/js/package.json b/js/package.json
new file mode 100644
index 00000000..a8737cfb
--- /dev/null
+++ b/js/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "mopidy",
+ "version": "0.0.0",
+ "devDependencies": {
+ "buster": "*",
+ "grunt": "*",
+ "grunt-buster": "*",
+ "phantomjs": "*"
+ },
+ "scripts": {
+ "test": "grunt test",
+ "build": "grunt build",
+ "watch": "grunt watch"
+ }
+}