Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name: 'repeater',
type: 'confirm',
default: false,
message: 'Do you want to add another User Pool Group',
});
}
// Get distinct list
const distinctSet = new Set(userPoolGroupList);
userPoolGroupList = Array.from(distinctSet);
// Sort the Array to get precedence
let sortedUserPoolGroupList = [];
if (userPoolGroupList && userPoolGroupList.length > 0) {
const sortPrompt = new Sort({
name: 'sortUserPools',
hint: `(Use ${chalk.green.bold('+')} to change the order)`,
message: 'Sort the user pool groups in order of preference',
choices: userPoolGroupList,
shiftLeft(...args) {
return this.shiftUp(...args);
},
shiftRight(...args) {
return this.shiftDown(...args);
},
});
sortedUserPoolGroupList = await sortPrompt.run();
}
return sortedUserPoolGroupList;
}
'use strict';
const { Sort } = require('enquirer');
const prompt = new Sort({
name: 'career',
message: 'Please rank the following in order of importance',
numbered: true,
choices: ['Recognition', 'Opportunity', 'Pay', 'Benefits', 'Co-workers']
});
prompt.run()
.catch(console.error);
'use strict';
const colors = require('ansi-colors');
const { Sort } = require('enquirer');
const prompt = new Sort({
name: 'colors',
message: 'Sort the colors in order of preference',
hint: 'Top is best, bottom is worst',
numbered: true,
choices: ['red', 'white', 'green', 'cyan', 'yellow'].map(n => ({
name: n,
message: colors[n](n)
}))
});
prompt.run()
.then(function(answer = []) {
console.log(answer);
console.log('Your preferred order of colors is:');
console.log(answer.map(key => colors[key](key)).join('\n'));
})