UNPKG

redhot

Version:

TypeScript Monorepo Management

62 lines (49 loc) 1.71 kB
#!/usr/bin/env node 'use strict' const program = require('commander') const findConfig = require('find-config') const { dirname, join } = require('path') const { cd } = require('shelljs') const { clear } = require('./util') const { init } = require('./subcommand/init') const { create } = require('./subcommand/create') const { exec } = require('./subcommand/exec') const { lint } = require('./subcommand/lint') const { test } = require('./subcommand/test') const { build } = require('./subcommand/build') const { commit } = require('./subcommand/commit') const { release } = require('./subcommand/release') // this could be generated with plugins in the future const plugins = [ init, create, exec, lint, test, build, commit, release ] exports.setup = setup function setup () { // get redhot version const version = require('../package.json').version // find location of configuration file const redhot = findConfig('redhot.json', { home: false }) // find and switch to plugins should be working from const workingDir = redhot !== null ? dirname(redhot) : process.cwd() cd(workingDir) // require this config file if possible // should only be impossible for `init` const config = redhot !== null ? Object.assign({}, require(redhot)) : null // setup overall command line stuff program.version(version) // initiaize all plugins plugins.forEach(function (plugin) { plugin(program, config, workingDir) }) // start program program.parse(process.argv) } try { // prefer using a local version if possible require(join(process.cwd(), 'node_modules/redhot/lib/cli')).setup() clear() console.log('using local version of redhot! \n') } catch (e) { setup() }