@@ -4,11 +4,7 @@ const { pathExists } = require('fs-extra');
4
4
const { getOptions, parseQuery } = require ( 'loader-utils' ) ;
5
5
6
6
const {
7
- exec,
8
- readFile,
9
- wait,
10
- packageExist,
11
- which,
7
+ exec, readFile, wait, packageExist, which,
12
8
} = require ( './lib/util' ) ;
13
9
const { getConfig, getLocalDependencies } = require ( './lib/truffle' ) ;
14
10
@@ -24,15 +20,16 @@ module.exports = async function loader(source) {
24
20
try {
25
21
const params = parseQuery ( this . resourceQuery || '?' ) ;
26
22
const options = getOptions ( this ) ;
27
- const network = ( options && options . network ) ? options . network : 'development' ;
23
+ const network = options && options . network ? options . network : 'development' ;
28
24
const disabled = options && options . disabled ;
29
25
const contractFolderPath = this . context ;
30
26
const cwd = path . resolve ( contractFolderPath , '..' ) ;
31
27
const contractFilePath = this . resourcePath ;
32
28
const config = await getConfig ( { network, cwd } ) ;
33
29
const contractsBuildDirectory = config . contracts_build_directory ;
34
30
const contractFileName = path . basename ( contractFilePath ) ;
35
- const contractName = params . contract || contractFileName . charAt ( 0 ) . toUpperCase ( ) + contractFileName . slice ( 1 , contractFileName . length - 4 ) ;
31
+ const contractName = params . contract
32
+ || contractFileName . charAt ( 0 ) . toUpperCase ( ) + contractFileName . slice ( 1 , contractFileName . length - 4 ) ;
36
33
const compiledContractPath = path . resolve ( contractsBuildDirectory , `${ contractName } .json` ) ;
37
34
38
35
// check if compiled contract exists
@@ -78,7 +75,12 @@ module.exports = async function loader(source) {
78
75
isZeppelinBusy = false ;
79
76
}
80
77
} else {
81
- callback ( new Error ( `${ oz } is required to support solidity hot-loading. Please run "npm i -D ${ oz } ", or disable hot-loading.` ) , '{}' ) ;
78
+ callback (
79
+ new Error (
80
+ `${ oz } is required to support solidity hot-loading. Please run "npm i -D ${ oz } ", or disable hot-loading.` ,
81
+ ) ,
82
+ '{}' ,
83
+ ) ;
82
84
// return because if zos not installed we should fail
83
85
return ;
84
86
}
@@ -95,7 +97,10 @@ module.exports = async function loader(source) {
95
97
// return result to webpack
96
98
callback ( null , solJSON ) ;
97
99
} else {
98
- callback ( new Error ( `The contract '${ compiledContractPath } ' doesn't exist. Try to compile your contracts first.` ) , '{}' ) ;
100
+ callback (
101
+ new Error ( `The contract '${ compiledContractPath } ' doesn't exist. Try to compile your contracts first.` ) ,
102
+ '{}' ,
103
+ ) ;
99
104
}
100
105
} catch ( e ) {
101
106
// report error here, because configuration seems to be lacking
0 commit comments