UNPKG

@afelio/toolbelt

Version:

Afelio – Design Toolbelt

118 lines (107 loc) 2.33 kB
const AbstractTask = require( __base + '/lib/abstract'); const util = require('util'); const TaskName = require( __base + '/helpers/TaskName' ); const browsers = new (require( __base + '/vo/browsers'))(); const inquirer = require('inquirer'); const _ = require('underscore'); /** * View Task **/ class Task extends AbstractTask { /** * Constructor * * @param {Config} config * @param {Gulp} gulp **/ constructor(config, gulp) { super(config, gulp); } /** * Return the description of the task * * @return String **/ get description() { return 'Help you out with the configuration.'; } /** * Return the name of the task * * @return String **/ get name() { return TaskName.CONFIG; } /** * Execute the task * * @TODO handle exceptions **/ execute() { this.configPlateforms(); } /** * Configure the plateforms to support * **/ configPlateforms() { let plateforms = []; this.startRequestForOsAndBrowser(); } async startRequestForOsAndBrowser() { // console.log(await browsers.getListOfChoices()); this.requestForOs() .then( data => { console.log('data', data); }) .catch(err => { console.log(err); }) } /** * Request for an os * * @return {Promise} **/ async requestForOs() { return inquirer .prompt({ type: 'checkbox', name: 'plateforms', message: 'Which plateform to support?', pageSize: 16, paginated: true, choices: await browsers.getListOfChoices( this.config.get('browserstack:plateforms') ), validate: function (answers) { if (answers.length >= 25) { return `Error: The limit is drawn to 25 browsers. You currently have selected ${answers.length}.`; } return true; } }) .catch(err => { console.log(err); }) } /** * Request for a browser * * @return {Promise} **/ requestForBrowsers() { return inquirer .prompt({ type: 'checkbox', name: 'browser', message: 'What browser?', choices: this.getBrowsers('Windows', '8') }); } } module.exports = Task;