Skip to content

Commit

Permalink
Merge pull request #61 from jaksart1/v3.0
Browse files Browse the repository at this point in the history
V3.0 - fix path detection to chaincode folder
  • Loading branch information
dshuffma-ibm authored Feb 12, 2017
2 parents 5eb25dd + e62d172 commit b080726
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion busters_js.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"public/js/singlejshash":"158611d7c4c5f15a53f22245ef688e2e"}
{"public/js/singlejshash":"b11d58063ff94e8aa5271f6544758c30"}
49 changes: 29 additions & 20 deletions utils/marbles_cc_lib/deploy_cc.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,39 @@ module.exports = function (chain, logger) {
//get the path from GOPATH to marble's chaincode folder (b/c hfc expects the path to be this way)
//hfc builds the path with: projDir = goPath + '/src/' + chaincodePath; - therefore chaincodePath must reference from GOPATH/src/
function screwy_path(chaincode_folder){
var pos = __dirname.indexOf(path.join(process.env.GOPATH, '/src/'));
if(pos === -1){
var msg = '[Deploy Error] Marbles is not inside your system GOPATH, please fix';
console.log('\n\n' + msg + '\n\n');
throw msg;
}
else{
var removedGo = __dirname.substring(process.env.GOPATH.length + 5); //remove GOPATH/src part from __dirname
console.log('[debug] removedGo from marbles path', removedGo);
if(!process.env.GOPATH) {
console.log('\n\n\n WARNING: GOPATH is not set! \n please set GOPATH to deploy chaincode\n\n\n');


var temp = __dirname.split('\\').join('/'); //convert windows path slashes
var parsed = temp.split('/');
var root_of_marbles = parsed[parsed.length-3]; //find name of marbles root dir
console.log('[debug] root_of_marbles path', root_of_marbles);

} else {

var pos3 = removedGo.indexOf(root_of_marbles);
var hfc_path = removedGo.substring(0, pos3 + root_of_marbles.length); //get path from GOPATH to marbles root dir
var pos = __dirname.indexOf(path.join(process.env.GOPATH, '/src/'));

if(pos === -1){
var msg = '[Deploy Error] Marbles is not inside your system GOPATH, please fix';
console.log('\n\n' + msg + '\n\n');
throw msg;
}
else{
var removedGo = __dirname.substring(process.env.GOPATH.length + 5); //remove GOPATH/src part from __dirname
console.log('[debug] removedGo from marbles path', removedGo);

var temp = __dirname.split('\\').join('/'); //convert windows path slashes
var parsed = temp.split('/');
var root_of_marbles = parsed[parsed.length-3]; //find name of marbles root dir
console.log('[debug] root_of_marbles path', root_of_marbles);

var pos3 = removedGo.indexOf(root_of_marbles);
var hfc_path = removedGo.substring(0, pos3 + root_of_marbles.length); //get path from GOPATH to marbles root dir

var ret = path.join(hfc_path, chaincode_folder); //path to chaincode dir
console.log('[debug] hfc compatible path to chaincode dir', ret);
var ret = path.join(hfc_path, chaincode_folder); //path to chaincode dir
console.log('[debug] hfc compatible path to chaincode dir', ret);

return ret;
//var debug = process.env.GOPATH + '/src/' + ret; //<- this is what hfc will build..
//console.log('debug', debug);
return ret;
//var debug = process.env.GOPATH + '/src/' + ret; //<- this is what hfc will build..
//console.log('debug', debug);
}
}
}

Expand Down

0 comments on commit b080726

Please sign in to comment.