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