All files index.js

100% Statements 15/15
45.45% Branches 5/11
100% Functions 1/1
100% Lines 15/15

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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 531x 1x 1x 1x                                           1x                   3x 1x 1x     2x   2x 1x     1x 1x 1x     1x  
const { OPTIONS } = require('./global');
const { cleanDist, createWpConfig, startWp } = require('./wp');
const { createTsConfig } = require('./ts');
const { standalone } = require('./standalone');
 
/**
 * Start `weldable`
 *
 * @module Init
 */
 
/**
 * Organize package functionality.
 *
 * @param {object} options
 * @param {boolean} options.isCreateTsConfigOnly
 * @param {boolean} options.isStandalone
 * @param {object} settings
 * @param {Function} settings.cleanDist
 * @param {Function} settings.createTsConfig
 * @param {Function} settings.createWpConfig
 * @param {Function} settings.standalone
 * @param {Function} settings.startWp
 * @returns {Promise<void>}
 */
const weldable = async (
  { isCreateTsConfigOnly, isStandalone } = OPTIONS,
  {
    cleanDist: aliasCleanDist = cleanDist,
    createTsConfig: aliasCreateTsConfig = createTsConfig,
    createWpConfig: aliasCreateWpConfig = createWpConfig,
    standalone: aliasStandalone = standalone,
    startWp: aliasStartWp = startWp
  } = {}
) => {
  if (isStandalone) {
    aliasStandalone();
    return;
  }
 
  aliasCreateTsConfig();
 
  if (isCreateTsConfigOnly) {
    return;
  }
 
  const webpackConfig = await aliasCreateWpConfig();
  aliasCleanDist();
  await aliasStartWp(webpackConfig);
};
 
module.exports = { weldable, OPTIONS };