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

Commit

Permalink
Merge pull request #19 from zie1ony/lazy-solc
Browse files Browse the repository at this point in the history
Load solc module in lazy fashion. Saves up to 2s on tests.
  • Loading branch information
gnidan authored Oct 24, 2017
2 parents 3a92910 + d5c73f4 commit ebb9e1b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
var Profiler = require("./profiler");
var OS = require("os");
var solc = require("solc");

// Clean up after solc.
var listeners = process.listeners("uncaughtException");
var solc_listener = listeners[listeners.length - 1];

if (solc_listener) {
process.removeListener("uncaughtException", solc_listener);
}

var path = require("path");
var fs = require("fs");
Expand Down Expand Up @@ -45,6 +36,17 @@ var compile = function(sources, options, callback) {
"solc"
]);

// Load solc module only when compilation is actually required.
var solc = require("solc");
// Clean up after solc.
var listeners = process.listeners("uncaughtException");
var solc_listener = listeners[listeners.length - 1];

if (solc_listener) {
process.removeListener("uncaughtException", solc_listener);
}


// Ensure sources have operating system independent paths
// i.e., convert backslashes to forward slashes; things like C: are left intact.
var operatingSystemIndependentSources = {};
Expand Down

0 comments on commit ebb9e1b

Please sign in to comment.