Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
wrapped(function(done) {
reporter.runningExecutable = fun();
let ret;
if (action.length > 0) { // function takes done callback
ret = reporter.runningExecutable.wrap(() => new Promise((resolve, reject) => {
const t: any = resolve;
t.fail = reject;
action(t);
}))();
} else {
ret = reporter.runningExecutable.wrap(action)();
}
if (isPromise(ret)) {
(ret as Promise).then(() => {
reporter.runningExecutable = null;
done();
}).catch(e => {
reporter.runningExecutable = null;
done.fail(e);
});
} else {
reporter.runningExecutable = null;
done();
}
}, timeout);
};
public step(name: string, body: (step: StepInterface) => any): any {
const wrappedStep = this.startStep(name);
let result;
try {
result = wrappedStep.run(body);
} catch (err) {
wrappedStep.endStep();
throw err;
}
if (isPromise(result)) {
const promise = result as Promise;
return promise
.then(a => {
wrappedStep.endStep();
return a;
})
.catch(e => {
wrappedStep.endStep();
throw e;
});
}
wrappedStep.endStep();
return result;
}
step(name: string, body: (step: StepInterface) => any): any {
const wrappedStep = this.startStep(name);
let result;
try {
result = wrappedStep.run(body);
} catch (err) {
wrappedStep.endStep();
throw err;
}
if (isPromise(result)) {
const promise = result as Promise;
return promise.then(a => {
wrappedStep.endStep();
return a;
}).catch(e => {
wrappedStep.endStep();
throw e;
});
} else {
wrappedStep.endStep();
return result;
}
}
step(name: string, body: (step: StepInterface) => any): any {
const wrappedStep = this.startStep(name);
let result;
try {
result = wrappedStep.run(body);
} catch (err) {
wrappedStep.endStep();
throw err;
}
if (isPromise(result)) {
const promise = result as Promise;
return promise.then(a => {
wrappedStep.endStep();
return a;
}).catch(e => {
wrappedStep.endStep();
throw e;
});
} else {
wrappedStep.endStep();
return result;
}
}