tailwindcss/src/cli/main.js

23 lines
588 B
JavaScript
Raw Normal View History

2018-09-13 21:37:10 -05:00
import commands from './commands'
2018-09-24 07:55:24 -05:00
import * as utils from './utils'
2018-09-13 21:37:10 -05:00
/**
* CLI application entrypoint.
*
* @param {string[]} cliArgs
* @return {Promise}
2018-09-13 21:37:10 -05:00
*/
export default function run(cliArgs) {
return new Promise((resolve, reject) => {
2018-09-24 07:55:24 -05:00
const params = utils.parseCliParams(cliArgs)
const command = commands[params[0]]
2018-09-24 07:55:24 -05:00
const options = command ? utils.parseCliOptions(cliArgs, command.optionMap) : {}
2018-09-13 21:37:10 -05:00
2018-09-24 07:55:24 -05:00
const commandPromise = command
? command.run(params.slice(1), options)
: commands.help.run(params)
2018-09-13 21:37:10 -05:00
2018-09-24 07:55:24 -05:00
commandPromise.then(resolve).catch(reject)
})
2018-09-13 21:37:10 -05:00
}