Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class TruffleConfig {
// The require-nocache module used to do this for us, but
// it doesn't bundle very well. So we've pulled it out ourselves.
//@ts-ignore
delete require.cache[Module._resolveFilename(file, module)];
delete originalRequire.cache[Module._resolveFilename(file, module)];
const staticConfig = originalRequire(file);

config.merge(staticConfig);
Expand Down
52 changes: 52 additions & 0 deletions packages/config/test/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,58 @@ describe("TruffleConfig.detect", () => {
});
});

describe("TruffleConfig.load", () => {
it("re-loads a config file after being modified", () => {
const options = {
workingDirectory: `${process.cwd()}/test`
};

fs.writeFileSync(
"./test/truffle-config.js",
`
module.exports = {
networks: {
development: {
url: "http://127.0.0.1:8545"
},
},
};
`
);
{
const config = TruffleConfig.detect(options);
delete config.networks["dashboard"];
assert.deepStrictEqual(config.networks, {
development: { url: "http://127.0.0.1:8545" }
});
}

fs.writeFileSync(
"./test/truffle-config.js",
`
module.exports = {
networks: {
development: {
url: "http://127.0.0.1:8545"
},
development2: {
url: "http://127.0.0.1:8546"
},
},
};
`
);
{
const config = TruffleConfig.detect(options);
delete config.networks["dashboard"];
assert.deepStrictEqual(config.networks, {
development: { url: "http://127.0.0.1:8545" },
development2: { url: "http://127.0.0.1:8546" }
});
}
});
});

describe("when it can't find a config file", () => {
beforeEach(() => {
sinon.stub(TruffleConfig, "search").returns(null);
Expand Down