test: actually fix race condition
This commit is contained in:
parent
f1c55ad5af
commit
1fecdafd02
|
@ -17,7 +17,14 @@ module.exports = {
|
|||
if (path !== join(FLECKS_CORE_ROOT, 'build', 'flecks.yml')) {
|
||||
return;
|
||||
}
|
||||
Object.entries(flecks.constructor.dealiasedConfig(config))
|
||||
const dealiasedConfig = flecks.constructor.dealiasedConfig(config);
|
||||
if (
|
||||
JSON.stringify(Object.keys(flecks.originalConfig).sort())
|
||||
!== JSON.stringify(Object.keys(dealiasedConfig).sort())
|
||||
) {
|
||||
throw new Error('build manifest keys changed!');
|
||||
}
|
||||
Object.entries(dealiasedConfig)
|
||||
.forEach(([fleck, value]) => {
|
||||
if (JSON.stringify(flecks.originalConfig[fleck]) !== JSON.stringify(value)) {
|
||||
const fleckList = flecks.flecksImplementing('@flecks/core.reload');
|
||||
|
|
|
@ -8,7 +8,6 @@ import {withServer} from './build/build';
|
|||
it('allows updates to fail', withServer(async ({server, socket}) => {
|
||||
expect((await socket.send({type: 'config.get', payload: 'comm.foo'})).payload)
|
||||
.to.equal('bar');
|
||||
const hmr = socket.waitForAction('hmr');
|
||||
await writeFile(
|
||||
join(server.path, 'build', 'flecks.yml'),
|
||||
`
|
||||
|
@ -18,7 +17,7 @@ it('allows updates to fail', withServer(async ({server, socket}) => {
|
|||
'comm:./comm': {foo: 'baz'}
|
||||
`,
|
||||
);
|
||||
await hmr;
|
||||
await socket.waitForAction('hmr');
|
||||
expect((await socket.send({type: 'config.get', payload: 'comm.foo'})).payload)
|
||||
.to.equal('baz');
|
||||
let restarted;
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
import {Flecks} from '@flecks/core';
|
||||
|
||||
export const hooks = {
|
||||
'@flecks/core.reload': (fleck, config) => {
|
||||
if ('comm' === fleck && 'fail' === config.foo) {
|
||||
throw new Error();
|
||||
}
|
||||
},
|
||||
'@flecks/core.hmr': async (path, M, flecks) => {
|
||||
const {socket} = flecks.server;
|
||||
socket.write(JSON.stringify({
|
||||
type: 'hmr',
|
||||
payload: path,
|
||||
}));
|
||||
},
|
||||
'@flecks/core.hmr': Flecks.priority(
|
||||
async (path, M, flecks) => {
|
||||
const {socket} = flecks.server;
|
||||
socket.write(JSON.stringify({
|
||||
type: 'hmr',
|
||||
payload: path,
|
||||
}));
|
||||
},
|
||||
{after: '@flecks/core'},
|
||||
),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user