diff --git a/lib/utils/utils.js b/lib/utils/utils.js index 6d92422f..7a3a5449 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -1,30 +1,23 @@ -let path = require('path'); -let globule = require('globule'); -let merge = require('merge'); let http = require('follow-redirects').http; let https = require('follow-redirects').https; -let shelljs = require('shelljs'); -var tar = require('tar'); -var propose = require('propose'); -var Web3 = require('web3'); -const constants = require('../constants'); - -//let fs = require('../core/fs.js'); -let o_fs = require('fs-extra'); function joinPath() { + const path = require('path'); return path.join.apply(path.join, arguments); } function filesMatchingPattern(files) { + const globule = require('globule'); return globule.find(files, {nonull: true}); } function fileMatchesPattern(patterns, intendedPath) { + const globule = require('globule'); return globule.isMatch(patterns, intendedPath); } function recursiveMerge(target, source) { + const merge = require('merge'); return merge.recursive(target, source); } @@ -81,6 +74,7 @@ function httpsGetJson(url, callback) { } function runCmd(cmd, options) { + const shelljs = require('shelljs'); let result = shelljs.exec(cmd, options || {silent: true}); if (result.code !== 0) { console.log("error doing.. " + cmd); @@ -93,10 +87,12 @@ function runCmd(cmd, options) { } function cd(folder) { + const shelljs = require('shelljs'); shelljs.cd(folder); } function sed(file, pattern, replace) { + const shelljs = require('shelljs'); shelljs.sed('-i', pattern, replace, file); } @@ -105,6 +101,7 @@ function exit(code) { } function downloadFile(url, dest, cb) { + const o_fs = require('fs-extra'); var file = o_fs.createWriteStream(dest); (url.substring(0,5) === 'https' ? https : http).get(url, function(response) { response.pipe(file); @@ -118,6 +115,8 @@ function downloadFile(url, dest, cb) { } function extractTar(filename, packageDirectory, cb) { + const o_fs = require('fs-extra'); + const tar = require('tar'); o_fs.createReadStream(filename).pipe( tar.x({ strip: 1, @@ -129,6 +128,7 @@ function extractTar(filename, packageDirectory, cb) { } function proposeAlternative(word, _dictionary, _exceptions) { + const propose = require('propose'); let exceptions = _exceptions || []; let dictionary = _dictionary.filter((entry) => { return exceptions.indexOf(entry) < 0; @@ -141,6 +141,7 @@ function pwd() { } function getExternalContractUrl(file) { + const constants = require('../constants'); let url; const RAW_URL = 'https://raw.githubusercontent.com/'; const MALFORMED_ERROR = 'Malformed Github URL for '; @@ -186,10 +187,12 @@ function getExternalContractUrl(file) { } function toChecksumAddress(address) { + const Web3 = require('web3'); return Web3.utils.toChecksumAddress(address); } function sha3(arg) { + const Web3 = require('web3'); return Web3.utils.sha3(arg); }