diff --git a/.travis.yml b/.travis.yml index bd3638e..f6312f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ notifications: email: true node_js: - stable + - 4 before_script: - npm prune after_success: diff --git a/README.md b/README.md index fd665e1..81e36b1 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ ![Build Status](https://img.shields.io/travis/kittikjs/kittik.svg) ![Coverage](https://img.shields.io/coveralls/kittikjs/kittik.svg) -![Downloads](https://img.shields.io/npm/dm/@kittikjs/kittik.svg) -![Downloads](https://img.shields.io/npm/dt/@kittikjs/kittik.svg) -![npm version](https://img.shields.io/npm/v/@kittikjs/kittik.svg) -![License](https://img.shields.io/npm/l/@kittikjs/kittik.svg) +![Downloads](https://img.shields.io/npm/dm/kittik.svg) +![Downloads](https://img.shields.io/npm/dt/kittik.svg) +![npm version](https://img.shields.io/npm/v/kittik.svg) +![License](https://img.shields.io/npm/l/kittik.svg) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) @@ -18,13 +18,7 @@ Install it via npm: ```shell -npm install -g kittik -``` - -Start your presentation: - -```shell -kittik start my_presentation.json +npm install kittik ``` ## License diff --git a/package.json b/package.json index c92c034..9eac33c 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,8 @@ "test": "babel-node ./node_modules/.bin/isparta cover _mocha" }, "dependencies": { - "charm": "1.0.0", - "commander": "2.9.0", "keypress": "0.2.1", - "kittik-animation-print": "1.0.0", + "kittik-animation-print": "1.1.0", "kittik-cursor": "1.0.2", "kittik-shape-rectangle": "1.0.2", "kittik-shape-text": "1.0.2" @@ -54,7 +52,7 @@ } }, "publishConfig": { - "tag": "next" + "tag": "latest" }, "release": { "branch": "master" diff --git a/src/Presentation.js b/src/Presentation.js index fddda31..b1fc3d2 100644 --- a/src/Presentation.js +++ b/src/Presentation.js @@ -11,7 +11,7 @@ import { Slide } from './Slide'; * @version 1.0.0 */ export class Presentation { - _cursor = Cursor.create([new Print().enable(), process.stdout], [process.stdin]).reset().hide(); + _cursor = Cursor.create([new Print().enable().setRandom(false), process.stdout], [process.stdin]).reset().hide(); _currentSlideIndex = 0; _slides = []; @@ -47,8 +47,11 @@ export class Presentation { * @returns {Presentation} */ renderSlide(index = this._currentSlideIndex) { + if (!this._slides[index]) return this; + this._cursor.reset().hide(); - if (this._slides[index]) this._slides[index].render(this._cursor); + this._slides[index].render(this._cursor); + return this; } @@ -58,8 +61,9 @@ export class Presentation { * @returns {Presentation} */ nextSlide() { - this._currentSlideIndex = this._currentSlideIndex + 1 > this._slides.length - 1 ? this._slides.length - 1 : this._currentSlideIndex + 1; - this.renderSlide(this._currentSlideIndex); + if (this._currentSlideIndex + 1 > this._slides.length - 1) return this; + + this.renderSlide(++this._currentSlideIndex); return this; } @@ -69,8 +73,9 @@ export class Presentation { * @returns {Presentation} */ prevSlide() { - this._currentSlideIndex = this._currentSlideIndex - 1 < 0 ? 0 : this._currentSlideIndex - 1; - this.renderSlide(this._currentSlideIndex); + if (this._currentSlideIndex - 1 < 0) return this; + + this.renderSlide(--this._currentSlideIndex); return this; } @@ -78,8 +83,8 @@ export class Presentation { * Closes the presentation and returns to terminal. */ exit() { - this._cursor.show().reset(); - process.exit(0); + this._cursor.reset().show(); + setTimeout(process.exit, 500); } /** diff --git a/src/Slide.js b/src/Slide.js index 9966b0a..c001844 100644 --- a/src/Slide.js +++ b/src/Slide.js @@ -1,6 +1,11 @@ import Rectangle from 'kittik-shape-rectangle'; import Text from 'kittik-shape-text'; +const shapesManager = { + rectangle: Rectangle, + text: Text +}; + /** * Creates a new slide with shapes. * @@ -28,10 +33,7 @@ export class Slide { * }]); */ constructor(shapes) { - this._shapes = shapes.map(shape => { - if (shape.name === 'Rectangle') return Rectangle.fromObject(shape); - if (shape.name === 'Text') return Text.fromObject(shape); - }); + this._shapes = shapes.map(shape => shapesManager[shape.name.toLowerCase()].fromObject(shape)); } /**