From 5397c4930cdfd8d439e5db3eb9a3d90b864d7702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Tue, 9 Sep 2014 00:08:40 +0200 Subject: [PATCH] start with this --- .gitignore | 1 + index.js | 9 +++++++++ package.json | 29 +++++++++++++++++++++++++++++ tests.js | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json create mode 100644 tests.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/index.js b/index.js new file mode 100644 index 0000000..e5fd4ff --- /dev/null +++ b/index.js @@ -0,0 +1,9 @@ +function Play(opts){ + this.child_process = opts.child_process + this.play = function(what){ + if (what) this.child_process.exec('cvlc ' + what) + } +} +module.exports = function(opts){ + return new Play(opts) +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..e087a48 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "play-sound", + "version": "0.0.0", + "description": "Play audio files by shelling out to available audio tool.", + "main": "index.js", + "scripts": { + "test": "node_modules/.bin/mocha tests.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/shime/play-sound.git" + }, + "keywords": [ + "audio", + "sound", + "play" + ], + "author": "Hrvoje Simic ", + "license": "MIT", + "bugs": { + "url": "https://github.com/shime/play-sound/issues" + }, + "homepage": "https://github.com/shime/play-sound", + "devDependencies": { + "expect.js": "^0.3.1", + "mocha": "^1.21.4", + "sinon": "^1.10.3" + } +} diff --git a/tests.js b/tests.js new file mode 100644 index 0000000..7842d9d --- /dev/null +++ b/tests.js @@ -0,0 +1,36 @@ +var expect = require('expect.js') + , sinon = require('sinon') + + +describe('cvlc has the maximum priorty', function(){ + it('tries to play with cvlc first', function(){ + var command = "cvlc beep.mp3" + , spy = sinon.spy() + + var cli = require('./')({ child_process: { + exec: spy + }}) + + cli.play('beep.mp3') + + expect(spy.calledOnce).to.be(true) + expect(spy.calledWith(command)).to.be(true) + }) + + it("doesn't try to play anything if nothing is passed", function(){ + var command = "cvlc beep.mp3" + , spy = sinon.spy() + + var cli = require('./')({ child_process: spy}) + cli.play() + + expect(spy.called).to.not.be(true) + }) + + it("doesn't error out if it's not available") +}) + +it('fallbacks to other players') + +describe('errors', function(){ +})