nx-helper-cli
Version:
This is a helper cli which helps get things done fast in a monorepo. mainly it's used with [nx.dev](http://google.com) tool but has many tools that may benefit anybody working in a monorepo architecture.
54 lines • 2.68 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
const chalk_1 = __importDefault(require("chalk"));
exports.getCurrentDirectory = () => {
return path.basename(process.cwd());
};
exports.directoryExists = (filePath) => {
return fs.existsSync(filePath);
};
exports.getRandomChalkColor = () => {
let colors = ['green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'gray'];
return colors[Math.floor(Math.random() * colors.length)];
};
exports.configToConcurrentlyAdapter = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
let extension = filePath.split('.').pop();
if (extension === 'json') {
// directly require the file then use it
return;
}
if (extension === 'js' || extension === 'ts') {
// console.log('full path', `${getCurrentDirectory()}/${filePath}`);
console.log('full path', `${__dirname}/${filePath}`);
console.log('koko');
// remove the extension from the path then require it then use it
let noExtensionPath = filePath.split('.').slice(0, -1).join('.');
let mod = yield Promise.resolve().then(() => __importStar(require(`${__dirname}/${filePath}`)));
console.log('module', mod);
return;
}
// error message that the extension is not a valid extension
console.log(chalk_1.default.red('This file extension is not supported only json , js , ts are the supported file extensions'));
});
//# sourceMappingURL=utils.js.map