Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/bs / dist / scripts / utils.js
Size: Mime:
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const safe_1 = __importDefault(require("colors/safe"));
const di_1 = require("@skava/di");
const resolveToRoot_1 = require("../config/resolveToRoot");
const appRootDir = di_1.config.get('appRootDir');
let erroring = false;
// @lint scripts
// eslint-disable-next-line
function log(options) {
    const { message, notify } = options;
    const title = options.title.toUpperCase();
    const level = options.level || 'info';
    const msg = `==> ${title} -> ${message}`;
    if (notify) {
        // same error, no spam popups
        if (erroring !== message) {
            // prevents spam notifications for warnings
            if (level === 'error' && message.toLowerCase().includes('error')) {
                erroring = message;
                // console.log({ [title]: message })
                // notifier.notify({
                //   title,
                //   message,
                // })
            }
            // onsole.log({ [title]: message })
            // notifier.notify({
            //   title,
            //   message,
            // })
        }
        if (level !== 'error') {
            console.log({ [title]: message });
            // notifier.notify({
            //   title,
            //   message,
            // })
        }
    }
    switch (level) {
        case 'warn':
            console.log(safe_1.default.yellow(msg));
            break;
        case 'error':
            console.log(safe_1.default.bgRed.white(msg));
            break;
        case 'info':
        default:
            console.log(safe_1.default.green(msg));
    }
}
exports.log = log;
function exec(command) {
    child_process_1.execSync(command, { stdio: 'inherit', cwd: appRootDir });
}
exports.exec = exec;
function toDefaultBuildPath() {
    // @todo make sure perf outweighs
    // assumption is the extra HMR files add overhead
    // but deleting the current output file may add bigger overhead
    // @todo probably use jet-fs to delete all matching glob except (index|main).js
    const buildOutputPath = resolveToRoot_1.resolveToRoot(process.env.BUILD_CONFIG_OUTPUT_PATH);
    return buildOutputPath;
}
function deleteDist(buildOutputPath = toDefaultBuildPath()) {
    // First clear the build output dir.
    try {
        exec(`yarn run rimraf ${buildOutputPath}`);
    }
    catch (subprocessException) {
        console.log({ subprocessException });
    }
}
exports.deleteDist = deleteDist;
//# sourceMappingURL=utils.js.map