Skip to content

Commit 924237a

Browse files
committed
chore: bump bree version
1 parent 3b11e32 commit 924237a

File tree

12 files changed

+70
-69
lines changed

12 files changed

+70
-69
lines changed

app/controllers/api/v1/control.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function checkJobName(ctx, next) {
1212
async function start(ctx) {
1313
const { jobName } = ctx.params;
1414

15-
ctx.bree.start(jobName);
15+
await ctx.bree.start(jobName);
1616

1717
ctx.body = {};
1818
}
@@ -28,7 +28,7 @@ async function stop(ctx) {
2828
async function run(ctx) {
2929
const { jobName } = ctx.params;
3030

31-
ctx.bree.run(jobName);
31+
await ctx.bree.run(jobName);
3232

3333
ctx.body = {};
3434
}
@@ -37,7 +37,7 @@ async function restart(ctx) {
3737
const { jobName } = ctx.params;
3838

3939
await ctx.bree.stop(jobName);
40-
ctx.bree.start(jobName);
40+
await ctx.bree.start(jobName);
4141

4242
ctx.body = {};
4343
}

app/controllers/api/v1/jobs.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,13 @@ async function add(ctx) {
5656
let jobs;
5757

5858
try {
59-
jobs = bree.add(body.jobs);
59+
jobs = await bree.add(body.jobs);
6060
} catch (err) {
6161
return ctx.throw(Boom.badData(err));
6262
}
6363

6464
if (body.start) {
65-
for (const job of jobs) {
66-
bree.start(job.name);
67-
}
65+
await Promise.all(jobs.map((j) => bree.start(j.name)));
6866
}
6967

7068
ctx.body = { jobs };

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ function plugin(opts, Bree) {
1717

1818
const oldInit = Bree.prototype.init;
1919

20-
Bree.prototype.init = function () {
21-
oldInit.bind(this)();
20+
Bree.prototype.init = async function () {
21+
await oldInit.bind(this)();
2222

2323
// assign bree to the context
2424
api.app.context.bree = this;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@commitlint/cli": "^17.0.2",
4949
"@commitlint/config-conventional": "^17.0.2",
5050
"ava": "^4.3.0",
51-
"bree": "^8.0.0",
51+
"bree": "^9.0.0",
5252
"codecov": "^3.8.1",
5353
"delay": "^5.0.0",
5454
"eslint": "^8.17.0",
@@ -107,7 +107,7 @@
107107
]
108108
},
109109
"peerDependencies": {
110-
"bree": "~8.0"
110+
"bree": "~9.0"
111111
},
112112
"prettier": {
113113
"singleQuote": true,

test/api/v1/jobs/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test.before(async (t) => {
3434

3535
t.context.api = t.context.api.auth(t.context.token, { type: 'bearer' });
3636

37-
t.context.bree.start();
37+
await t.context.bree.start();
3838
});
3939

4040
test.serial('successfully', async (t) => {

test/api/v1/jobs/post.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test.before(async (t) => {
1616

1717
t.context.api = t.context.api.auth(t.context.token, { type: 'bearer' });
1818

19-
t.context.bree.start();
19+
await t.context.bree.start();
2020
});
2121

2222
test('successfully add one job', async (t) => {

test/api/v1/sse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test.before(async (t) => {
3333

3434
t.context.api = t.context.api.auth(t.context.token, { type: 'bearer' });
3535

36-
t.context.bree.start();
36+
await t.context.bree.start();
3737
});
3838

3939
test('successfully connect to sse', async (t) => {

test/api/v1/stop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test.before(async (t) => {
3333

3434
t.context.api = t.context.api.auth(t.context.token, { type: 'bearer' });
3535

36-
t.context.bree.start();
36+
await t.context.bree.start();
3737

3838
await delay(200);
3939
});

test/plugin/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ test('api does not exist on bree constructor', (t) => {
1515
t.is(typeof Bree.api, 'undefined');
1616
});
1717

18-
test('api does exist on bree instance', (t) => {
18+
test('api does exist on bree instance', async (t) => {
1919
const { Bree } = t.context;
2020

2121
const bree = new Bree(baseConfig);
22+
await bree.init();
2223

2324
t.log(bree);
2425
// just to make sure this works correctly

test/plugin/options.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Bree = require('bree');
44
const { plugin } = require('../..');
55
const { baseConfig } = require('../utils');
66

7-
test('can modify options', (t) => {
7+
test('can modify options', async (t) => {
88
t.not(plugin.$i, true);
99

1010
Bree.extend(plugin, {
@@ -14,6 +14,7 @@ test('can modify options', (t) => {
1414
});
1515

1616
const bree = new Bree(baseConfig);
17+
await bree.init();
1718

1819
t.is(bree.api.config.port, 3000);
1920
t.is(bree.api.config.jwt.secret, 'thisisasecret');

0 commit comments

Comments
 (0)