Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
debug('res', typeof res, res)
if (typeof res === 'function') {
res = res()
}
if (isValidFSM(res)) {
return res
} else {
let err = ''
try {
// maybe the code did a console.log?
const maybe = openwhiskComposer.deserialize(JSON.parse(logMessage))
if (isValidFSM(maybe)) {
return maybe
}
} catch (e) {
err = e
}
throw new Error(`Unable to compile your composition
${err}
${errorMessage}`)
}
} catch (err) {
const junkMatch = err.stack.match(/\s+at Object\.exports\.runInNewContext/)
|| err.stack.match(/\s+at Object\.runInNewContext/)
|| err.stack.match(/\s+at fs\.readFile/),
_message = err.message.indexOf('Invalid argument to compile') >= 0? 'Your source code did not produce a valid app.' : (!junkMatch ? e.stack : err.stack.substring(0, junkMatch.index).replace(/\s+.*create-from-source([^\n])*/g, '\n').replace(/(evalmachine.)/g, filename).replace(/\s+at createScript([^\n])*/g, '\n').trim()),
exports.deserializeFSM = fsm => openwhiskComposer.deserialize(fsm)
exports.getFSM = entity => {
const fsmAnnotation = exports.fsmAnnotation(entity)
if (fsmAnnotation) {
return openwhiskComposer.deserialize(fsmAnnotation.value)
}
}