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

Commit

Permalink
Add lazy-require for command dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
LogvinovLeon committed Feb 9, 2017
1 parent e73af69 commit f98178a
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 69 deletions.
6 changes: 3 additions & 3 deletions lib/commands/build.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var Config = require("truffle-config");
var Build = require("../build");

var command = {
command: 'build',
description: 'Execute build pipeline (if configuration present)',
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var Build = require("../build");

var config = Config.detect(options);
Build.build(config, done);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/compile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
var Config = require("truffle-config");
var Contracts = require("../contracts");

var command = {
command: 'compile',
description: 'Compile contract source files',
Expand All @@ -11,6 +8,9 @@ var command = {
}
},
run: function (options, done) {
var Config = require("truffle-config");
var Contracts = require("../contracts");

var config = Config.detect(options);
Contracts.compile(config, done);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/commands/console.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var Config = require("truffle-config");
var Console = require("../repl");
var Environment = require("../environment");

var command = {
command: 'console',
description: 'Run a console with contract abstractions and commands available',
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var Console = require("../repl");
var Environment = require("../environment");

var config = Config.detect(options);

// This require a smell?
Expand Down
8 changes: 4 additions & 4 deletions lib/commands/create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
var Config = require("truffle-config");
var ConfigurationError = require("../errors/configurationerror");
var create = require("../create");

var command = {
command: 'create',
description: 'Helper to create new contracts, migrations and tests',
Expand All @@ -12,6 +8,10 @@ var command = {
}
},
run: function (options, done) {
var Config = require("truffle-config");
var ConfigurationError = require("../errors/configurationerror");
var create = require("../create");

var config = Config.detect(options);

var type = config.type;
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/digest.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var Config = require("truffle-config");
var Package = require("../package");

var command = {
command: 'digest',
description: 'Show publishable information about the current project',
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var Package = require("../package");

var config = Config.detect(options);
Package.digest(config, function(err, results) {
if (err) return done(err);
Expand Down
14 changes: 7 additions & 7 deletions lib/commands/exec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
var Config = require("truffle-config");
var ConfigurationError = require("../errors/configurationerror");
var Require = require("truffle-require");
var Environment = require("../environment");
var path = require("path");
var OS = require("os");

var command = {
command: 'exec',
description: 'Execute a JS module within this Truffle environment',
Expand All @@ -14,6 +7,13 @@ var command = {
}
},
run: function (options, done) {
var Config = require("truffle-config");
var ConfigurationError = require("../errors/configurationerror");
var Require = require("truffle-require");
var Environment = require("../environment");
var path = require("path");
var OS = require("os");

var config = Config.detect(options);

var file = options.file;
Expand Down
8 changes: 4 additions & 4 deletions lib/commands/init.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var Config = require("truffle-config");
var Init = require("truffle-init");
var OS = require("os");

var command = {
command: 'init',
description: 'Initialize new Ethereum project with example contracts and tests',
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var Init = require("truffle-init");
var OS = require("os");

var config = Config.default().with({
logger: console
});
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var Config = require("truffle-config");
var Package = require("../package");

var command = {
command: 'install',
description: 'Install a package from the Ethereum Package Registry',
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var Package = require("../package");

if (options._ && options._.length > 0) {
options.packages = options._;
}
Expand Down
16 changes: 8 additions & 8 deletions lib/commands/migrate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
var OS = require("os");
var Config = require("truffle-config");
var Contracts = require("../contracts");
var Resolver = require("truffle-resolver");
var Artifactor = require("truffle-artifactor");
var Migrate = require("truffle-migrate");
var Environment = require("../environment");

var command = {
command: 'migrate',
description: 'Run migrations to deploy contracts',
Expand All @@ -25,6 +17,14 @@ var command = {
}
},
run: function (options, done) {
var OS = require("os");
var Config = require("truffle-config");
var Contracts = require("../contracts");
var Resolver = require("truffle-resolver");
var Artifactor = require("truffle-artifactor");
var Migrate = require("truffle-migrate");
var Environment = require("../environment");

var config = Config.detect(options);

Contracts.compile(config, function(err) {
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/networks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
var Config = require("truffle-config");
var Networks = require("../networks");

var command = {
command: 'networks',
description: 'Show addresses for deployed contracts on each network',
Expand All @@ -12,6 +9,9 @@ var command = {
}
},
run: function (options, done) {
var Config = require("truffle-config");
var Networks = require("../networks");

var config = Config.detect(options);

if (options.clean) {
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/publish.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var Config = require("truffle-config");
var Package = require("../package");

var command = {
command: 'publish',
description: 'Publish a package to the Ethereum Package Registry',
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var Package = require("../package");

var config = Config.detect(options);
Package.publish(config, done);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/commands/serve.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
var Serve = require("../serve");
var Config = require("truffle-config");
var watch = require("./watch");

var command = {
command: 'serve',
description: 'Serve the build directory on localhost and watch for changes',
Expand All @@ -12,6 +8,10 @@ var command = {
}
},
run: function (options, done) {
var Serve = require("../serve");
var Config = require("truffle-config");
var watch = require("./watch");

var config = Config.detect(options);
Serve.start(config, function() {
watch.run(options, done);
Expand Down
24 changes: 13 additions & 11 deletions lib/commands/test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
var OS = require("os");
var dir = require("node-dir");
var temp = require("temp");
var Config = require("truffle-config");
var Resolver = require("truffle-resolver");
var Artifactor = require("truffle-artifactor");
var Test = require("../test");
var fs = require("fs");
var copy = require("../copy");
var Environment = require("../environment");

var command = {
command: 'test',
description: 'Run Mocha and Solidity tests',
builder: {},
run: function (options, done) {
var OS = require("os");
var dir = require("node-dir");
var temp = require("temp");
var Config = require("truffle-config");
var Resolver = require("truffle-resolver");
var Artifactor = require("truffle-artifactor");
var Test = require("../test");
var fs = require("fs");
var path = require("path");
var mkdirp = require("mkdirp");
var copy = require("../copy");
var Environment = require("../environment");

var config = Config.detect(options);
//config.network = "test";

Expand Down
4 changes: 2 additions & 2 deletions lib/commands/version.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var pkg = require("../../package.json");

var command = {
command: 'version',
description: 'Show version number and exit',
builder: {},
run: function (options, done) {
var pkg = require("../../package.json");

options.logger.log("Truffle v" + pkg.version);
done();
}
Expand Down
14 changes: 7 additions & 7 deletions lib/commands/watch.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var Build = require("../build");
var Config = require("truffle-config");
var chokidar = require("chokidar");
var path = require("path");
var colors = require("colors");
var Contracts = require("../contracts");

var command = {
command: 'watch',
description: 'Watch filesystem for changes and rebuild the project automatically',
builder: {},
run: function (options, done) {
var Build = require("../build");
var Config = require("truffle-config");
var chokidar = require("chokidar");
var path = require("path");
var colors = require("colors");
var Contracts = require("../contracts");

var config = Config.detect(options);

var printSuccess = function() {
Expand Down

0 comments on commit f98178a

Please sign in to comment.