@fivethree/billy-core
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -16,3 +16,3 @@ import { LaneType, LaneContext, JobType, HookType, HookName, WebHookType } from './types'; | ||
processAsyncArray(array: any[], asyncFunc: any): Promise<void>; | ||
getHook(type: 'BEFORE_ALL' | 'AFTER_ALL' | 'AFTER_EACH' | 'BEFORE_EACH' | 'ERROR'): HookType; | ||
getHook(type: 'BEFORE_ALL' | 'AFTER_ALL' | 'AFTER_EACH' | 'BEFORE_EACH' | 'ERROR'): LaneType; | ||
getLaneContext(lane: LaneType): LaneContext; | ||
@@ -19,0 +19,0 @@ runHook(lane: LaneType, ...args: any[]): Promise<any>; |
@@ -88,5 +88,5 @@ "use strict"; | ||
]); | ||
yield this.runHook(this.getHook('BEFORE_ALL').lane); | ||
yield this.runHook(this.getHook('BEFORE_ALL')); | ||
yield this.takeLane(answer.lane); | ||
yield this.runHook(this.getHook('AFTER_ALL').lane); | ||
yield this.runHook(this.getHook('AFTER_ALL')); | ||
}); | ||
@@ -101,3 +101,3 @@ } | ||
catch (err) { | ||
yield this.runHook(this.getHook('ERROR').lane); | ||
yield this.runHook(this.getHook('ERROR')); | ||
console.error(err); | ||
@@ -109,7 +109,7 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.runHook(this.getHook('BEFORE_ALL').lane); | ||
yield this.runHook(this.getHook('BEFORE_ALL')); | ||
yield this.processAsyncArray(lanes, (lane) => __awaiter(this, void 0, void 0, function* () { | ||
yield this.takeLane(lane); | ||
})); | ||
yield this.runHook(this.getHook('AFTER_ALL').lane); | ||
yield this.runHook(this.getHook('AFTER_ALL')); | ||
}); | ||
@@ -126,3 +126,4 @@ } | ||
getHook(type) { | ||
return this.hooks.find(hook => hook.name === type); | ||
const hook = this.hooks.find(hook => hook.name === type); | ||
return hook && hook.lane ? hook.lane : null; | ||
} | ||
@@ -146,3 +147,3 @@ getLaneContext(lane) { | ||
catch (err) { | ||
yield this.runHook(this.getHook('ERROR').lane, ...args); | ||
yield this.runHook(this.getHook('ERROR'), ...args); | ||
console.error(err); | ||
@@ -157,5 +158,5 @@ } | ||
console.log('run scheduled lane ' + job.lane.name + ': ' + fireDate); | ||
yield this.runHook(this.getHook('BEFORE_ALL').lane); | ||
yield this.runHook(this.getHook('BEFORE_ALL')); | ||
yield this.takeLane(job.lane); | ||
yield this.runHook(this.getHook('AFTER_ALL').lane); | ||
yield this.runHook(this.getHook('AFTER_ALL')); | ||
})); | ||
@@ -227,6 +228,6 @@ job.scheduler = instance; | ||
this.app.instance[lane.name] = (...args) => __awaiter(this, void 0, void 0, function* () { | ||
yield this.app.runHook(this.app.getHook('BEFORE_EACH').lane); | ||
yield this.app.runHook(this.app.getHook('BEFORE_EACH')); | ||
console.log(chalk.green(`taking lane ${lane.name}`)); | ||
yield func(...args); | ||
yield this.app.runHook(this.app.getHook('AFTER_EACH').lane); | ||
yield this.app.runHook(this.app.getHook('AFTER_EACH')); | ||
}); | ||
@@ -233,0 +234,0 @@ })); |
{ | ||
"name": "@fivethree/billy-core", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "cli plugin system core.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -84,7 +84,7 @@ import { LaneType, LaneContext, JobType, HookType, HookName, WebHookType } from './types'; | ||
await this.runHook(this.getHook('BEFORE_ALL').lane); | ||
await this.runHook(this.getHook('BEFORE_ALL')); | ||
await this.takeLane(answer.lane); | ||
await this.runHook(this.getHook('AFTER_ALL').lane); | ||
await this.runHook(this.getHook('AFTER_ALL')); | ||
@@ -98,3 +98,3 @@ } | ||
} catch (err) { | ||
await this.runHook(this.getHook('ERROR').lane); | ||
await this.runHook(this.getHook('ERROR')); | ||
@@ -106,7 +106,7 @@ console.error(err); | ||
async takeMultiple(lanes: LaneType[]) { | ||
await this.runHook(this.getHook('BEFORE_ALL').lane); | ||
await this.runHook(this.getHook('BEFORE_ALL')); | ||
await this.processAsyncArray(lanes, async (lane) => { | ||
await this.takeLane(lane); | ||
}) | ||
await this.runHook(this.getHook('AFTER_ALL').lane); | ||
await this.runHook(this.getHook('AFTER_ALL')); | ||
} | ||
@@ -120,4 +120,5 @@ | ||
getHook(type: 'BEFORE_ALL' | 'AFTER_ALL' | 'AFTER_EACH' | 'BEFORE_EACH' | 'ERROR'): HookType { | ||
return this.hooks.find(hook => hook.name === type); | ||
getHook(type: 'BEFORE_ALL' | 'AFTER_ALL' | 'AFTER_EACH' | 'BEFORE_EACH' | 'ERROR') { | ||
const hook = this.hooks.find(hook => hook.name === type); | ||
return hook && hook.lane ? hook.lane : null; | ||
} | ||
@@ -142,3 +143,3 @@ | ||
} catch (err) { | ||
await this.runHook(this.getHook('ERROR').lane, ...args); | ||
await this.runHook(this.getHook('ERROR'), ...args); | ||
@@ -154,5 +155,5 @@ console.error(err); | ||
console.log('run scheduled lane ' + job.lane.name + ': ' + fireDate); | ||
await this.runHook(this.getHook('BEFORE_ALL').lane); | ||
await this.runHook(this.getHook('BEFORE_ALL')); | ||
await this.takeLane(job.lane); | ||
await this.runHook(this.getHook('AFTER_ALL').lane); | ||
await this.runHook(this.getHook('AFTER_ALL')); | ||
}); | ||
@@ -227,6 +228,6 @@ job.scheduler = instance; | ||
this.app.instance[lane.name] = async (...args) => { | ||
await this.app.runHook(this.app.getHook('BEFORE_EACH').lane); | ||
await this.app.runHook(this.app.getHook('BEFORE_EACH')); | ||
console.log(chalk.green(`taking lane ${lane.name}`)); | ||
await func(...args); | ||
await this.app.runHook(this.app.getHook('AFTER_EACH').lane); | ||
await this.app.runHook(this.app.getHook('AFTER_EACH')); | ||
} | ||
@@ -233,0 +234,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24928
622