Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.
Merged
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
15 changes: 13 additions & 2 deletions src/debugAdapter/runtimeInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {mkdirpSync, writeFileSync} from 'fs-extra';
import {fetchAndCompileForDebugger} from '@truffle/fetch-and-compile';
import Config from '@truffle/config';
import {Environment} from '@truffle/environment';
import Module from 'module';
import * as os from 'os';
import * as path from 'path';

Expand Down Expand Up @@ -136,13 +137,23 @@ export default class RuntimeInterface extends EventEmitter {
* @returns
*/
public async attach(args: Required<DebuggerTypes.DebugArgs>): Promise<void> {
// Retreives the truffle configuration file
try {
const originalRequire = eval('require');
// Mimics the behavior of `Config.detect` until https://github.com/trufflesuite/truffle/pull/5728 gets merged.
const file = path.join(args.workingDirectory, 'truffle-config.js');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be a problem if we have the truffle config file with another name?

Copy link
Contributor Author

@acuarica acuarica Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be an issue, but it's not currently supported. The Config.detect method expects the same name. This is related to #256.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right :)

Thank you @acuarica!

const resolvedFileName = (Module as any)._resolveFilename(file, module);
delete originalRequire.cache[resolvedFileName];
} catch {
/**/
}

// Retrieves the truffle configuration file
const config = Config.detect({workingDirectory: args.workingDirectory});

// Validate the network parameter
RuntimeInterface.validateNetwork(config, args);

// Retreives the environment configuration
// Retrieves the environment configuration
await Environment.detect(config);

// Gets the contracts compilation
Expand Down