2016-08-21 16:02:02 +00:00
|
|
|
var fs = require('fs');
|
|
|
|
var grunt = require('grunt');
|
|
|
|
var mkdirp = require('mkdirp');
|
|
|
|
|
|
|
|
var Pipeline = function(options) {
|
2016-08-22 03:40:05 +00:00
|
|
|
this.buildDir = options.buildDir;
|
|
|
|
this.contractsFiles = options.contractsFiles;
|
|
|
|
this.assetFiles = options.assetFiles;
|
2016-08-21 16:02:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Pipeline.prototype.build = function(abi) {
|
2016-08-22 03:40:05 +00:00
|
|
|
for(var targetFile in this.assetFiles) {
|
2016-08-21 16:02:02 +00:00
|
|
|
|
2016-08-22 03:40:05 +00:00
|
|
|
var content = this.assetFiles[targetFile].map(function(file) {
|
|
|
|
console.log("reading " + file.filename);
|
|
|
|
if (file.filename === 'embark.js') {
|
|
|
|
return file.content + "\n" + abi;
|
2016-08-21 16:02:02 +00:00
|
|
|
} else {
|
2016-08-22 03:40:05 +00:00
|
|
|
return file.content;
|
2016-08-21 16:02:02 +00:00
|
|
|
}
|
|
|
|
}).join("\n");
|
|
|
|
|
|
|
|
var dir = targetFile.split('/').slice(0, -1).join('/');
|
2016-08-22 03:40:05 +00:00
|
|
|
console.log("creating dir " + this.buildDir + dir);
|
|
|
|
mkdirp.sync(this.buildDir + dir);
|
2016-08-21 16:02:02 +00:00
|
|
|
|
2016-08-22 03:40:05 +00:00
|
|
|
fs.writeFileSync(this.buildDir + targetFile, content);
|
2016-08-21 16:02:02 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Pipeline;
|
|
|
|
|