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

Internal improvement: Clean up develop and console code #2095

Merged
merged 13 commits into from Jun 27, 2019
Merged
24 changes: 12 additions & 12 deletions packages/truffle-core/lib/commands/console.js
@@ -1,4 +1,4 @@
var command = {
const command = {
command: "console",
description:
"Run a console with contract abstractions and commands available",
Expand All @@ -19,29 +19,29 @@ var command = {
]
},
run: function(options, done) {
var Config = require("truffle-config");
var Console = require("../console");
var Environment = require("../environment");
const Config = require("truffle-config");
const Console = require("../console");
const Environment = require("../environment");

var config = Config.detect(options);
const config = Config.detect(options);

// This require a smell?
var commands = require("./index");
var excluded = ["console", "init", "watch", "develop"];
const commands = require("./index");
const excluded = ["console", "init", "watch", "develop"];

var available_commands = Object.keys(commands).filter(function(name) {
const availableCommands = Object.keys(commands).filter(name => {
return excluded.indexOf(name) === -1;
});

var console_commands = {};
available_commands.forEach(function(name) {
console_commands[name] = commands[name];
const consoleCommands = {};
availableCommands.forEach(name => {
consoleCommands[name] = commands[name];
});

Environment.detect(config)
.then(() => {
const c = new Console(
console_commands,
consoleCommands,
config.with({ noAliases: true })
);
c.start(done);
Expand Down
6 changes: 3 additions & 3 deletions packages/truffle-core/lib/commands/develop.js
Expand Up @@ -21,19 +21,19 @@ const command = {
const commands = require("./index");
const excluded = ["console", "develop", "unbox", "init"];

const available_commands = Object.keys(commands).filter(
const availableCommands = Object.keys(commands).filter(
name => !excluded.includes(name)
);

const console_commands = available_commands.reduce(
const consoleCommands = availableCommands.reduce(
(acc, name) => Object.assign({}, acc, { [name]: commands[name] }),
{}
);

Environment.develop(config, ganacheOptions)
.then(() => {
const c = new Console(
console_commands,
consoleCommands,
config.with({ noAliases: true })
);
c.start(done);
Expand Down