All files / scripts compile.js

6.25% Statements 1/16
0% Branches 0/2
0% Functions 0/3
6.25% Lines 1/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 371x                                                                        
module.exports = async function(files, options) {
  options = require('./utils/injectConfig')(options);
 
  const path = require('path');
  const fs = require('fs-extra');
  const {
    compile,
    getAllFiles,
    printOrSilent
  } = require('@haechi-labs/vvisp-utils');
 
  fs.ensureDirSync(path.join('./', 'build'));
  fs.ensureDirSync(path.join('build', 'contracts'));
 
  if (files.length === 0) {
    files = getAllFiles(path.join('./', 'contracts'), filePath => {
      return path.parse(filePath).ext === '.sol';
    });
  }
 
  const output = await compile(files, options);
 
  // TODO: output file refine
  Object.entries(output.contracts).forEach(
    ([contractNamePath, contractContent]) => {
      const contractName = path.parse(contractNamePath).name;
      contractContent.contractName = contractName;
      fs.writeJsonSync(
        path.join('./build/contracts', contractName + '.json'),
        contractContent,
        { spaces: '  ' }
      );
    }
  );
  printOrSilent('Compiling Finished!', options);
};