-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Set context vars #3317
Set context vars #3317
Conversation
…me warnings we already saw in the parent
…ild process, and add comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find on the yargs @fainashalts . I have a few comments on the context logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interpret
method duplicates logic of runSpawn
that can be refactored out.
@@ -118,7 +122,6 @@ class Console extends EventEmitter { | |||
}); | |||
|
|||
this.resetContractsInConsoleContext(abstractions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you consider renaming this function to addContractReferencesToReplContext
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a reset and not an addition. It happens at the end of every command, and if the contracts have changed they get reset to the new ones. Happy to discuss further but this was the original name of this function in the replManager and I think it is still apt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content of the function mutates repl.context instead of a Console. Not a hill I want to stop on :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @fainashalts :) Sorry about the Object Spread usage!
@@ -118,7 +122,6 @@ class Console extends EventEmitter { | |||
}); | |||
|
|||
this.resetContractsInConsoleContext(abstractions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content of the function mutates repl.context instead of a Console. Not a hill I want to stop on :)
This PR seeks to allow the re-introduction of the child process for commands from #3255, the
spawn-repl
branch, while fixing a few issues:truffle develop
andtruffle console
commands. It appears the context containing the contracts' artifacts was not properly being set for the new repl.To test that this bug is fixed:
a) Run
truffle console
ortruffle develop
in an existing project that has already migrated its contracts.b) Enter the name of one of its contracts.
Expected: The artifact for that contract is printed in your terminal.
a) Run
truffle console
ortruffle develop
in an existing project for which a migration has not been run.b) Enter the name of a contract in the project.
Expected: Error thrown
c) Run the
migrate
commandd) Enter the name of a contract in the project
Expected: The artifact is printed in your terminal.
stdio
handling ofstderr
in the spawn process, to keep warnings that have already been consoled in the parent process from being printed again. Specifically, this is in relation to the error about having two config files:This PR also pull this
this.provision()
function call outside of the try/catch it was in, to ensure that if there is an error in that function that we are able to see it.This PR also fixes the use of yargs for properly getting and passing the network in the
console-child
file. (good catch on this bug @cds-amal!)This work additionally ensures that assignments/scripts created in Javascript inside the child process persist between commands. You should be able to run
const [ownerAccount] = accounts
and accessownerAccount
throughout yourdevelop
orconsole
session.Many thanks to @cds-amal for letting me bounce ideas off of him while figuring out this bug!