All files / src/scripts build.js

100% Statements 16/16
100% Branches 0/0
100% Functions 2/2
100% Lines 16/16
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 37 38 39 40 41 42 431x 1x   1x 1x   1x 2x   2x   2x   2x           2x             2x   2x               1x 2x 2x     1x  
const fs = require('fs-extra')
const path = require('path')
 
const { generateManifest } = require('../manifest')
const { updateIndexHtmls, writeJsonFile, packCovenants } = require('../file')
 
const build = async options => {
  const { config, manifest, artifacts } = options
 
  const location = path.relative(process.cwd(), artifacts)
 
  setupDist(location)
 
  const covenantFilenames = await packCovenants(
    location,
    config.covenants,
    options
  )
 
  const newManifest = generateManifest(
    location,
    config,
    covenantFilenames,
    manifest
  )
 
  writeJsonFile(`${location}/interbit.manifest.json`, newManifest)
 
  updateIndexHtmls({
    config,
    chains: newManifest.chains
  })
}
 
// Helpers
 
const setupDist = location => {
  fs.removeSync(location)
  fs.mkdirpSync(location)
}
 
module.exports = build