diff --git a/remix-solidity/src/compiler/compiler.js b/remix-solidity/src/compiler/compiler.js index dcf9e95d7d..407c1bdb3e 100644 --- a/remix-solidity/src/compiler/compiler.js +++ b/remix-solidity/src/compiler/compiler.js @@ -73,7 +73,7 @@ function Compiler (handleImportCall) { function onInternalCompilerLoaded () { if (worker === null) { var compiler - var userAgent = (typeof (navigator) != 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : "-" + var userAgent = (typeof (navigator) !== 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : '-' if (typeof (window) === 'undefined' || userAgent.indexOf(' electron/') > -1) { compiler = require('solc') } else { diff --git a/remix-tests/src/compiler.js b/remix-tests/src/compiler.js index 6ffbff1633..f43a9cab65 100644 --- a/remix-tests/src/compiler.js +++ b/remix-tests/src/compiler.js @@ -2,7 +2,6 @@ let fs = require('fs') var async = require('async') var path = require('path') -const signale = require('signale') let RemixCompiler = require('remix-solidity').Compiler String.prototype.regexIndexOf = function (regex, startpos) { @@ -10,6 +9,9 @@ String.prototype.regexIndexOf = function (regex, startpos) { return (indexOf >= 0) ? (indexOf + (startpos || 0)) : indexOf } +var userAgent = (typeof (navigator) !== 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : '-' +var isBrowser = !(typeof (window) === 'undefined' || userAgent.indexOf(' electron/') > -1) + // TODO: replace this with remix's own compiler code function compileFileOrFiles (filename, isDirectory, cb) { let compiler, filepath @@ -52,7 +54,7 @@ function compileFileOrFiles (filename, isDirectory, cb) { ], function (err, result) { let errors = (result.errors || []).filter((e) => e.type === 'Error' || e.severity === 'error') if (errors.length > 0) { - signale.fatal(errors) + if (!isBrowser) require('signale').fatal(errors) return cb(new Error('errors compiling')) } cb(err, result.contracts) @@ -91,7 +93,7 @@ function compileContractSources (sources, importFileCb, cb) { ], function (err, result) { let errors = (result.errors || []).filter((e) => e.type === 'Error' || e.severity === 'error') if (errors.length > 0) { - signale.fatal(errors) + if (!isBrowser) require('signale').fatal(errors) return cb(new Error('errors compiling')) } cb(err, result.contracts) diff --git a/remix-tests/src/index.js b/remix-tests/src/index.js index 0bd322382d..3dfd689ff4 100644 --- a/remix-tests/src/index.js +++ b/remix-tests/src/index.js @@ -1,7 +1,6 @@ const async = require('async') const path = require('path') const fs = require('fs') -const { Signale } = require('signale') require('colors') let Compiler = require('./compiler.js') @@ -17,28 +16,6 @@ var createWeb3Provider = function () { return web3 } -// signale configuration -const options = { - types: { - result: { - badge: '\t✓', - label: '', - color: 'greenBright' - }, - name: { - badge: '\n\t◼', - label: '', - color: 'white' - }, - error: { - badge: '\t✘', - label: '', - color: 'redBright' - } - } -} -const signale = new Signale(options) - var runTestSources = function (contractSources, testCallback, resultCallback, finalCallback, importFileCb) { async.waterfall([ function compile (next) { @@ -119,6 +96,28 @@ var runTestSources = function (contractSources, testCallback, resultCallback, fi } var runTestFiles = function (filepath, isDirectory, web3) { + const { Signale } = require('signale') + // signale configuration + const options = { + types: { + result: { + badge: '\t✓', + label: '', + color: 'greenBright' + }, + name: { + badge: '\n\t◼', + label: '', + color: 'white' + }, + error: { + badge: '\t✘', + label: '', + color: 'redBright' + } + } + } + const signale = new Signale(options) async.waterfall([ function compile (next) { Compiler.compileFileOrFiles(filepath, isDirectory, next)