UNPKG

particle-cli

Version:

Simple Node commandline application for working with your Particle devices and using the Particle Cloud

40 lines (36 loc) 716 B
'use strict'; const Spinner = require('cli-spinner').Spinner; module.exports = function spinnerMixin(obj) { Object.assign(obj, { newSpin(str) { this.__spin = new Spinner(str); return this.__spin; }, startSpin() { if (!this.__spin){ return; } this.__spin.start(); }, stopSpin() { if (!this.__spin){ return; } this.__spin.stop(true); }, stopSpinAfterPromise(promise) { return promise.then((value) => { this.stopSpin(); return value; }, (error) => { this.stopSpin(); throw error; }); }, showBusySpinnerUntilResolved(message, promise){ this.newSpin(message); this.startSpin(); return this.stopSpinAfterPromise(promise); } }); };