diff --git a/packages/embark-utils/src/collections.ts b/packages/embark-utils/src/collections.ts index 20164e379..f59255e47 100644 --- a/packages/embark-utils/src/collections.ts +++ b/packages/embark-utils/src/collections.ts @@ -7,3 +7,7 @@ export function last(array: any) { export function recursiveMerge(target: any, source: any) { return merge.recursive(target, source); } + +export function compact(array: any) { + return array.filter((n: any) => n); +} diff --git a/packages/embark-utils/src/index.js b/packages/embark-utils/src/index.js index 96b3483c2..7d117d3a1 100644 --- a/packages/embark-utils/src/index.js +++ b/packages/embark-utils/src/index.js @@ -25,7 +25,7 @@ import AccountParser from './accountParser'; const { extendZeroAddressShorthand, replaceZeroAddressShorthand } = AddressUtils; -import { last, recursiveMerge } from './collections'; +import { compact, last, recursiveMerge } from './collections'; function timer(ms) { const then = Date.now(); @@ -229,6 +229,7 @@ const Utils = { jsonFunctionReplacer, fuzzySearch, canonicalHost, + compact, copyToClipboard, deconstructUrl, defaultCorsHost, diff --git a/packages/embark/src/lib/modules/blockchain_process/blockchain.js b/packages/embark/src/lib/modules/blockchain_process/blockchain.js index 130cefe3d..7288f05eb 100644 --- a/packages/embark/src/lib/modules/blockchain_process/blockchain.js +++ b/packages/embark/src/lib/modules/blockchain_process/blockchain.js @@ -3,13 +3,12 @@ const {spawn, exec} = require('child_process'); const path = require('path'); const fs = require('../../core/fs.js'); const constants = require('embark-core/constants'); -const utils = require('../../utils/utils.js'); const GethClient = require('./gethClient.js'); const ParityClient = require('./parityClient.js'); const Proxy = require('./proxy'); import { IPC } from 'embark-core'; -import {defaultHost, dockerHostSwap, AccountParser} from 'embark-utils'; +import { compact, defaultHost, dockerHostSwap, AccountParser} from 'embark-utils'; const Logger = require('embark-logger'); // time between IPC connection attempts (in ms) @@ -231,7 +230,7 @@ Blockchain.prototype.run = function () { self.logger.error(err.message); return; } - args = utils.compact(args); + args = compact(args); let full_cmd = cmd + " " + args.join(' '); self.logger.info(__("running: %s", full_cmd.underline).green); diff --git a/packages/embark/src/lib/modules/codeRunner/vm.ts b/packages/embark/src/lib/modules/codeRunner/vm.ts index a90856b28..064b34313 100644 --- a/packages/embark/src/lib/modules/codeRunner/vm.ts +++ b/packages/embark/src/lib/modules/codeRunner/vm.ts @@ -2,11 +2,11 @@ import { each } from "async"; import { Callback, Logger } /* supplied by @types/embark in packages/embark-typings */ from "embark"; import { NodeVM, NodeVMOptions } from "vm2"; -import { recursiveMerge } from "embark-utils"; +import { compact, recursiveMerge } from "embark-utils"; const fs = require("./fs"); const path = require("path"); -const { isEs6Module, compact } = require("../../utils/utils"); +const { isEs6Module } = require("../../utils/utils"); const WEB3_INVALID_RESPONSE_ERROR: string = "Invalid JSON RPC response"; diff --git a/packages/embark/src/lib/utils/utils.js b/packages/embark/src/lib/utils/utils.js index b5ce2945c..09cfcb819 100644 --- a/packages/embark/src/lib/utils/utils.js +++ b/packages/embark/src/lib/utils/utils.js @@ -282,10 +282,6 @@ function isValidDomain(v) { return isValid; } -function compact(array) { - return array.filter(n => n); -} - function groupBy(array, key) { return array.reduce(function (rv, x) { (rv[x[key]] = rv[x[key]] || []).push(x); @@ -397,7 +393,6 @@ module.exports = { extractZip, getExternalContractUrl, normalizeInput, - compact, groupBy, interceptLogs, errorMessage,