diff --git a/lib/watch/index.js b/lib/watch/index.js index 81de0b2f..12adee00 100644 --- a/lib/watch/index.js +++ b/lib/watch/index.js @@ -39,8 +39,7 @@ const watch = function (args, ignoreWatch, verboseWatch) { const run = (event) => { const childEvent = { childEvent: event } - const env = Object.assign({}, process.env, childEvent, require('dotenv').config().parsed) - + const env = Object.assign({}, require('dotenv').config().parsed, process.env, childEvent) const _child = cp.fork(forkPath, args, { env, cwd: process.cwd(), diff --git a/test/start.test.js b/test/start.test.js index 59299776..0994c167 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -642,7 +642,7 @@ test('should reload the env on restart when watching', { skip: process.platform }) t.equal(r2.response.statusCode, 200) - t.same(JSON.parse(r2.body), { hello: 'planet' }) + t.same(JSON.parse(r2.body), { hello: 'world' }) /* world because when making a restart the server still passes the arguments that change the environment variable */ await fastifyEmitter.stop() })