Merge pull request #966 from ethereum/removeSignale

Don't use signale in the browser
pull/7/head
yann300 6 years ago committed by GitHub
commit da2052afa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      remix-solidity/src/compiler/compiler.js
  2. 3
      remix-tests/package.json
  3. 8
      remix-tests/src/compiler.js
  4. 45
      remix-tests/src/index.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 {

@ -50,6 +50,9 @@
"web3": "1.0.0-beta.34",
"winston": "^3.0.0"
},
"peerDependencies": {
"yo-yoify": "latest"
},
"devDependencies": {
"mocha": "^5.1.0"
}

@ -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)

@ -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)

Loading…
Cancel
Save