Merge pull request #492 from embark-framework/features/cute-require-fixed

Override require to replace embark.require by only require
This commit is contained in:
Jonathan Rainville 2018-06-07 16:33:53 -04:00 committed by GitHub
commit 2b05a54270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 192 additions and 49 deletions

View File

@ -43,6 +43,16 @@ module.exports = {
process.exit();
};
// Override require to enable `require('Embark/contracts/contractName');`
const Module = require('module');
const originalRequire = require('module').prototype.require;
Module.prototype.require = function(requireName) {
if (requireName.startsWith('Embark')) {
return test.require(...arguments);
}
return originalRequire.apply(this, arguments);
};
// TODO: this global here might not be necessary at all
global.web3 = global.embark.web3;

157
package-lock.json generated
View File

@ -1832,7 +1832,7 @@
"browserify-zlib": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz",
"integrity": "sha1-KGlFnZqjviRf6P4sofRuLn9U1z8=",
"integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==",
"requires": {
"pako": "1.0.6"
}
@ -3194,7 +3194,7 @@
"domain-browser": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
"integrity": "sha1-PTH1AZGmdJ3RN1p/Ui6CPULlTto="
"integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA=="
},
"drbg.js": {
"version": "1.0.1",
@ -3219,6 +3219,11 @@
"typechecker": "2.1.0"
}
},
"easy-stack": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/easy-stack/-/easy-stack-1.0.0.tgz",
"integrity": "sha1-EskbMIWjfwuqM26UhurEv5Tj54g="
},
"ecc-jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
@ -3312,7 +3317,7 @@
"errno": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
"integrity": "sha1-RoTXF3mtOa8Xfj8AeZb3xnyFJhg=",
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==",
"requires": {
"prr": "1.0.1"
}
@ -4102,6 +4107,11 @@
"es5-ext": "0.10.42"
}
},
"event-pubsub": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/event-pubsub/-/event-pubsub-4.3.0.tgz",
"integrity": "sha512-z7IyloorXvKbFx9Bpie2+vMJKKx1fH1EN5yiTfp8CiLOTptSYy1g8H4yDpGlEdshL1PBiFtBHepF2cNsqeEeFQ=="
},
"eventemitter2": {
"version": "0.4.14",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz",
@ -6500,6 +6510,19 @@
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.3.tgz",
"integrity": "sha512-H7ErYLM34CvDMto3GbD6xD0JLUGYXR3QTcH6B/tr4Hi/QpSThnCsIp+Sy5FRTw3B0d6py4HcNkW7nO/wdtGWEw=="
},
"js-message": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/js-message/-/js-message-1.0.5.tgz",
"integrity": "sha1-IwDSSxrwjondCVvBpMnJz8uJLRU="
},
"js-queue": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/js-queue/-/js-queue-2.0.0.tgz",
"integrity": "sha1-NiITz4YPRo8BJfxslqvBdCUx+Ug=",
"requires": {
"easy-stack": "1.0.0"
}
},
"js-sha3": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.7.0.tgz",
@ -6577,7 +6600,7 @@
"json-loader": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz",
"integrity": "sha1-3KFKcCNf+C8KyaOr62DTN6NlGF0="
"integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w=="
},
"json-parse-better-errors": {
"version": "1.0.1",
@ -8332,10 +8355,20 @@
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.4.tgz",
"integrity": "sha512-8Df0906+tq/omxuCZD6PqhPaQDYuyJ1d+VITgxoIA8zvQd1ru+nMJcDChHH324MWitIgbVkAkQoGEEVJNpn/PA=="
},
"node-ipc": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/node-ipc/-/node-ipc-9.1.1.tgz",
"integrity": "sha512-FAyICv0sIRJxVp3GW5fzgaf9jwwRQxAKDJlmNFUL5hOy+W4X/I5AypyHoq0DXXbo9o/gt79gj++4cMr4jVWE/w==",
"requires": {
"event-pubsub": "4.3.0",
"js-message": "1.0.5",
"js-queue": "2.0.0"
}
},
"node-libs-browser": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.1.0.tgz",
"integrity": "sha1-X5QmPUBPbkR2fXJpAf/wVHjWAN8=",
"integrity": "sha512-5AzFzdoIMb89hBGMZglEegffzgRg+ZFoUmisQ8HI4j1KDdpx13J0taNp2y9xPbur6W61gepGDDotGBVQ7mfUCg==",
"requires": {
"assert": "1.4.1",
"browserify-zlib": "0.2.0",
@ -8799,7 +8832,7 @@
"os-locale": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz",
"integrity": "sha1-QrwpAKa1uL0XN2yOiCtlr8zyS/I=",
"integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==",
"requires": {
"execa": "0.7.0",
"lcid": "1.0.0",
@ -8896,7 +8929,7 @@
"pako": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
"integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg="
"integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg=="
},
"parse-asn1": {
"version": "5.1.0",
@ -12792,7 +12825,7 @@
"webpack": {
"version": "3.11.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-3.11.0.tgz",
"integrity": "sha512-3kOFejWqj5ISpJk4Qj/V7w98h9Vl52wak3CLiw/cDOfbVTq7FeoZ0SdoHHY9PYlHr50ZS42OfvzE2vB4nncKQg==",
"integrity": "sha1-d9pFGx17SxF62vQaGpO1dC8k2JQ=",
"requires": {
"acorn": "5.5.3",
"acorn-dynamic-import": "2.0.2",
@ -13020,8 +13053,10 @@
"p-each-series": "1.0.0",
"p-lazy": "1.0.0",
"prettier": "1.13.4",
"supports-color": "5.4.0",
"v8-compile-cache": "2.0.0",
"webpack-addons": "1.1.5",
"yargs": "11.1.0",
"yeoman-environment": "2.2.0",
"yeoman-generator": "2.0.5"
},
@ -13050,7 +13085,8 @@
"integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==",
"requires": {
"ansi-styles": "3.2.1",
"escape-string-regexp": "1.0.5"
"escape-string-regexp": "1.0.5",
"supports-color": "5.4.0"
}
},
"cliui": {
@ -13059,6 +13095,7 @@
"integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==",
"requires": {
"string-width": "2.1.1",
"strip-ansi": "4.0.0",
"wrap-ansi": "2.1.0"
}
},
@ -13085,7 +13122,8 @@
"integrity": "sha512-jox/62b2GofV1qTUQTMPEJSDIGycS43evqYzD/KVtEb9OCoki9cnacUPxCrZa7JfPzZSYOCZhu9O9luaMxAX8g==",
"requires": {
"graceful-fs": "4.1.11",
"memory-fs": "0.4.1"
"memory-fs": "0.4.1",
"tapable": "1.0.0"
}
},
"got": {
@ -13108,6 +13146,7 @@
"pify": "3.0.0",
"safe-buffer": "5.1.1",
"timed-out": "4.0.1",
"url-parse-lax": "3.0.0",
"url-to-options": "1.0.1"
}
},
@ -13132,6 +13171,7 @@
"run-async": "2.3.0",
"rxjs": "5.5.11",
"string-width": "2.1.1",
"strip-ansi": "4.0.0",
"through": "2.3.8"
}
},
@ -13153,10 +13193,44 @@
"p-finally": "1.0.0"
}
},
"prepend-http": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz",
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"requires": {
"ansi-regex": "3.0.0"
}
},
"supports-color": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
"requires": {
"has-flag": "3.0.0"
}
},
"tapable": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.0.0.tgz",
"integrity": "sha512-dQRhbNQkRnaqauC7WqSJ21EEksgT0fYZX2lqXzGkpo8JNig9zGZTYoMGvyI2nWmXlE2VSVXVDu7wLVGu/mQEsg=="
},
"underscore": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz",
"integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI="
},
"url-parse-lax": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz",
"integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=",
"requires": {
"prepend-http": "2.0.0"
}
}
}
},
@ -13187,7 +13261,7 @@
"webpack-sources": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz",
"integrity": "sha1-oQHrrlnWUHNU1x2AE5UKOot6WlQ=",
"integrity": "sha512-aqYp18kPphgoO5c/+NaUvEeACtZjMESmDChuD3NBciVpah3XpMEU9VAAtIaB1BsfJWWTSdv8Vv1m3T0aRk2dUw==",
"requires": {
"source-list-map": "2.0.0",
"source-map": "0.6.1"
@ -13196,7 +13270,7 @@
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM="
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
}
}
},
@ -13444,6 +13518,65 @@
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI="
},
"yargs": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz",
"integrity": "sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A==",
"requires": {
"cliui": "4.1.0",
"decamelize": "1.2.0",
"find-up": "2.1.0",
"get-caller-file": "1.0.2",
"os-locale": "2.1.0",
"require-directory": "2.1.1",
"require-main-filename": "1.0.1",
"set-blocking": "2.0.0",
"string-width": "2.1.1",
"which-module": "2.0.0",
"y18n": "3.2.1",
"yargs-parser": "9.0.2"
},
"dependencies": {
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg="
},
"cliui": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz",
"integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==",
"requires": {
"string-width": "2.1.1",
"strip-ansi": "4.0.0",
"wrap-ansi": "2.1.0"
}
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"requires": {
"ansi-regex": "3.0.0"
}
}
}
},
"yargs-parser": {
"version": "9.0.2",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-9.0.2.tgz",
"integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=",
"requires": {
"camelcase": "4.1.0"
},
"dependencies": {
"camelcase": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0="
}
}
},
"yauzl": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.9.1.tgz",

View File

@ -1,7 +1,7 @@
/*global contract, config, it, embark*/
/*global contract, config, it*/
const assert = require('assert');
const AnotherStorage = embark.require('Embark/contracts/AnotherStorage');
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
const AnotherStorage = require('Embark/contracts/AnotherStorage');
const SimpleStorage = require('Embark/contracts/SimpleStorage');
config({
contracts: {

View File

@ -1,8 +1,8 @@
/*global contract, config, it, embark*/
/*global contract, config, it*/
const assert = require('assert');
const SomeContract = embark.require('Embark/contracts/SomeContract');
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
const MyToken2 = embark.require('Embark/contracts/MyToken2');
const SomeContract = require('Embark/contracts/SomeContract');
const SimpleStorage = require('Embark/contracts/SimpleStorage');
const MyToken2 = require('Embark/contracts/MyToken2');
config({
contracts: {

View File

@ -1,6 +1,6 @@
/*global contract, config, it, embark*/
/*global contract, config, it*/
const assert = require('assert');
const Test2 = embark.require('Embark/contracts/Test2');
const Test2 = require('Embark/contracts/Test2');
config({
contracts: {

View File

@ -1,6 +1,6 @@
/*global contract, config, it, embark*/
/*global contract, config, it*/
const assert = require('assert');
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
const SimpleStorage = require('Embark/contracts/SimpleStorage');
config({
contracts: {

View File

@ -1,10 +1,10 @@
/*global describe, config, it, embark*/
/*global describe, config, it*/
const assert = require('assert');
const Token = embark.require('Embark/contracts/Token');
const MyToken = embark.require('Embark/contracts/MyToken');
const MyToken2 = embark.require('Embark/contracts/MyToken2');
const AlreadyDeployedToken = embark.require('Embark/contracts/AlreadyDeployedToken');
const Test = embark.require('Embark/contracts/Test');
const Token = require('Embark/contracts/Token');
const MyToken = require('Embark/contracts/MyToken');
const MyToken2 = require('Embark/contracts/MyToken2');
const AlreadyDeployedToken = require('Embark/contracts/AlreadyDeployedToken');
const Test = require('Embark/contracts/Test');
config({
contracts: {

View File

@ -1,7 +1,7 @@
/*global contract, config, it, embark, web3*/
/*global contract, config, it, web3*/
const assert = require('assert');
const AnotherStorage = embark.require('Embark/contracts/AnotherStorage');
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
const AnotherStorage = require('Embark/contracts/AnotherStorage');
const SimpleStorage = require('Embark/contracts/SimpleStorage');
let accounts;

View File

@ -1,8 +1,8 @@
/*global contract, config, it, embark*/
/*global contract, config, it*/
const assert = require('assert');
const SomeContract = embark.require('Embark/contracts/SomeContract');
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
const MyToken2 = embark.require('Embark/contracts/MyToken2');
const SomeContract = require('Embark/contracts/SomeContract');
const SimpleStorage = require('Embark/contracts/SimpleStorage');
const MyToken2 = require('Embark/contracts/MyToken2');
config({
contracts: {

View File

@ -1,6 +1,6 @@
/*global contract, config, it, embark*/
/*global contract, config, it*/
const assert = require('assert');
const Test2 = embark.require('Embark/contracts/Test2');
const Test2 = require('Embark/contracts/Test2');
config({
contracts: {

View File

@ -1,7 +1,7 @@
/*global contract, config, it, embark*/
/*global contract, config, it*/
const assert = require('assert');
const PluginStorage = embark.require('Embark/contracts/PluginStorage');
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
const PluginStorage = require('Embark/contracts/PluginStorage');
const SimpleStorage = require('Embark/contracts/SimpleStorage');
config({
contracts: {

View File

@ -1,5 +1,5 @@
/*global contract, config, it, embark, assert, web3*/
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
/*global contract, config, it, assert, web3*/
const SimpleStorage = require('Embark/contracts/SimpleStorage');
let accounts;
config({

View File

@ -1,10 +1,10 @@
/*global describe, config, it, embark*/
/*global describe, config, it*/
const assert = require('assert');
const Token = embark.require('Embark/contracts/Token');
const MyToken = embark.require('Embark/contracts/MyToken');
const MyToken2 = embark.require('Embark/contracts/MyToken2');
const AlreadyDeployedToken = embark.require('Embark/contracts/AlreadyDeployedToken');
const Test = embark.require('Embark/contracts/Test');
const Token = require('Embark/contracts/Token');
const MyToken = require('Embark/contracts/MyToken');
const MyToken2 = require('Embark/contracts/MyToken2');
const AlreadyDeployedToken = require('Embark/contracts/AlreadyDeployedToken');
const Test = require('Embark/contracts/Test');
config({
contracts: {