'use strict';

const tools = require('../../scripts/utils/tools');
const buildPackageUtils = require('../../scripts/utils/build/package/build-package-utils');
const configUtils = require('../../scripts/csdr/config/config-utils');

Promise.resolve()
  .then(() => {
    const { subEntry } = tools.getArgs();
    const pkg = configUtils.packages.getPackage();
    return buildPackageUtils.buildSubEntry(pkg, subEntry);
  })
  .then(() => {
    tools.logSuccess();
  })
  .catch((e) => {
    tools.logError('ERROR found while building package');
    console.error(e);
    process.exit(1);
  })
