Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.error(err)
} else {
resolve()
}
})
})
const action = getEntity()
debug('addWskflow action', action)
if (action.type !== 'compositions') {
// no need to generate wskflows if this isn't a composition
return
}
if (!filepath) {
filepath = await mktemp(extension(action.exec.kind))
}
const source = editor.getValue()
await write(source)
const ast = await generateAST(source, filepath)
if (ast.statusCode || ast.code) {
// some error generating the AST
editor.clearDecorations()
handleParseError(ast, filepath, editor)
} else {
if (differentASTs(action.ast, ast)) {
action.ast = ast
await updateView()
}
}
new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const tmp = require('tmp')
tmp.file({ prefix: 'shell-', postfix: extension(app.exec.kind) }, (err, filepath, fd, cleanup) => {
if (err) {
reject(err)
} else {
fs.write(fd, app.exec.code, async err => {
if (err) {
reject(err)
} else {
const { REPL } = await import('@kui-shell/core/api/repl')
return REPL.pexec(
`wsk app update ${REPL.encodeComponent(app.name)} ${REPL.encodeComponent(filepath)} --kind ${
app.exec.kind
}`
)
.then(app => {
cleanup()
resolve(app)