@modyo/cli
Version:
Modyo CLI Command line to expose local development tools
33 lines (32 loc) • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const debug_1 = tslib_1.__importDefault(require("debug"));
const path_exists_1 = tslib_1.__importDefault(require("../utils/path-exists"));
const run_build_command_1 = tslib_1.__importDefault(require("./run-build-command"));
const debug = (0, debug_1.default)('push/check-widget.ts');
async function checkWidget(buildDirectory, buildCommand) {
core_1.ux.action.start('Checking if build directory exists');
if (!(await (0, path_exists_1.default)(buildDirectory))) {
debug('build directory not exists');
core_1.ux.action.stop('Build directory not exists');
await (0, run_build_command_1.default)(buildCommand);
core_1.ux.action.start('Checking if build directory exists');
if (!(await (0, path_exists_1.default)(buildDirectory))) {
core_1.ux.action.stop('Build Directory not exist and cannot be created!');
throw new Error('Build Directory not exist and cannot be created!');
}
}
core_1.ux.action.stop('done');
debug('build directory exists');
core_1.ux.action.start('Checking if index.html exists');
if (!(await (0, path_exists_1.default)(buildDirectory, 'index.html'))) {
core_1.ux.action.stop('index.html not exist!');
debug('index.html not exists');
throw new Error('index.html not exist!');
}
debug('index.html exists');
core_1.ux.action.stop('done');
}
exports.default = checkWidget;