-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Hi, I'm trying to get Synchronize.js working with Inquirer but I've tried everything and can't get it to work with its promises:
package.json
{
"dependencies": {
"inquirer": "^3.0.6",
"synchronize": "^2.0.0"
}
}
index.js
const inquirer = require('inquirer');
const sync = require('synchronize');
const fiber = sync.fiber;
const await = sync.await;
const defer = sync.defer;
// // works
// inquirer.prompt([{
// type: 'input',
// name: 'first_name',
// message: 'What\'s your first name'
// }]).then(function (answers) {
// console.log('First name:', answers.first_name);
// });
// doesn't work
fiber(function() {
const answers = await(
inquirer.prompt([{
type: 'input',
name: 'first_name',
message: 'What\'s your first name'
}]).then(defer())
);
console.log(answers);
});
$ yarn
$ node index.js
? What's your first name? Zack
/Users/zackmorris/Desktop/testing/appium-vynyl/node_modules/synchronize/sync.js:111
fiber.throwInto(err)
^
[object Object]
I've tried every permutation, even variations of #41 but can't get it to work.
Can you update your documentation for promises? Or else show how to de-promisify something? I tried wrapping the promise in my own callback function to fit the form of your examples but it still didn't work for some reason.
By comparison, here's the same example with asyncawait and Inquirer:
package.json
{
"dependencies": {
"asyncawait": "^1.0.6",
"inquirer": "^3.0.6"
}
}
index.js
const async = require('asyncawait/async');
const await = require('asyncawait/await');
const inquirer = require('inquirer');
async (function () {
const answers = await(
inquirer.prompt([{
type: 'input',
name: 'first_name',
message: 'What\'s your first name?'
}])
);
console.log('First name:', answers.first_name);
})();
$ yarn
$ node index.js
? What's your first name? Zack
First name: Zack
Thanx!
Anemy
Metadata
Metadata
Assignees
Labels
No labels