Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit bcbc026

Browse files
authored
Merge pull request #5780 from trufflesuite/remove-invalidation
remove `require` cache invalidation
2 parents d945752 + d5b0970 commit bcbc026

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

packages/config/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@truffle/events": "^0.1.19",
2626
"@truffle/provider": "^0.2.64",
2727
"conf": "^10.1.2",
28+
"debug": "^4.3.1",
2829
"find-up": "^2.1.0",
2930
"lodash": "^4.17.21",
3031
"original-require": "^1.0.1"

packages/config/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import path from "path";
22
import merge from "lodash/merge";
3-
import Module from "module";
43
import findUp from "find-up";
54
import Conf from "conf";
65
import TruffleError from "@truffle/error";
76
import originalRequire from "original-require";
87
import { getInitialConfig, configProps } from "./configDefaults";
98
import { EventManager } from "@truffle/events";
9+
import debugModule from "debug";
10+
const debug = debugModule("config");
1011

1112
const DEFAULT_CONFIG_FILENAME = "truffle-config.js";
1213
const BACKUP_CONFIG_FILENAME = "truffle.js"; // old config filename
@@ -117,6 +118,7 @@ class TruffleConfig {
117118
if (typeof clone[key] === "object" && this._deepCopy.includes(key)) {
118119
this[key] = merge(this[key], clone[key]);
119120
} else {
121+
debug("setting key -- %o -- to -- %o", key, clone[key]);
120122
this[key] = clone[key];
121123
}
122124
} catch (e) {
@@ -162,6 +164,7 @@ class TruffleConfig {
162164
}
163165

164166
public static detect(options: any = {}, filename?: string): TruffleConfig {
167+
debug("callling Config.detect with filename -- %o", filename);
165168
let configFile;
166169
const configPath = options.config;
167170

@@ -181,17 +184,15 @@ class TruffleConfig {
181184
}
182185

183186
public static load(file: string, options: any = {}): TruffleConfig {
187+
debug("calling Config.load with file -- %o", file);
184188
const workingDirectory = options.config
185189
? process.cwd()
186190
: path.dirname(path.resolve(file));
187191

188192
const config = new TruffleConfig(undefined, workingDirectory, undefined);
189193

190-
// The require-nocache module used to do this for us, but
191-
// it doesn't bundle very well. So we've pulled it out ourselves.
192-
//@ts-ignore
193-
delete require.cache[Module._resolveFilename(file, module)];
194194
const staticConfig = originalRequire(file);
195+
debug("the static config is -- %o", staticConfig);
195196

196197
config.merge(staticConfig);
197198
config.merge(options);

packages/core/test/lib/commands/config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ describe("config", function () {
1111
let output = "";
1212
let memStream;
1313

14-
before(function () {
14+
beforeEach(function () {
1515
config = createTestProject(path.join(__dirname, "../../sources/metacoin"));
1616
config.logger = { log: val => val && memStream.write(val) };
17-
});
18-
19-
beforeEach(function () {
2017
memStream = new MemoryStream();
2118
memStream.on("data", data => {
2219
output += data.toString();

0 commit comments

Comments
 (0)