Skip to content

fix promise detection #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var replHistory = require('repl.history')
var vm = require('vm')
var exec = require('child_process').exec
var loadPackages = require('./index')
var isPromise = require('is-promise')

const TRYMODULE_PATH = process.env.TRYMODULE_PATH || path.resolve((os.homedir()), '.trymodule')
const TRYMODULE_HISTORY_PATH = process.env.TRYMODULE_HISTORY_PATH || path.resolve(TRYMODULE_PATH, 'repl_history')
Expand Down Expand Up @@ -74,7 +75,7 @@ if (hasFlag('--clear')) {
var result = script.runInContext(replServer.context)
// Some libraries use non-native Promise implementations
// (ie lib$es6$promise$promise$$Promise)
if (result instanceof Promise || (typeof result === 'object' && typeof result.then === 'function')) {
if (isPromise(result)) {
console.log('Returned a Promise. waiting for result...')
result.then(function (val) {
callback(null, val)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"license": "MIT",
"dependencies": {
"colors": "^1.1.2",
"is-promise": "^2.1.0",
"npmi": "^1.0.1",
"repl.history": "^0.1.3"
},
Expand Down