UNPKG

create-jslib

Version:

CLI tool for building JavaScript libraries.

34 lines (31 loc) 1.08 kB
module.exports = cli => { cli.injectFeature({ name: 'TypeScript', value: 'ts', short: 'TS', description: 'Add support for the TypeScript language', link: 'https://github.com/logan70/create-jslib/tree/master/packages/jslib-plugin-typescript', plugins: ['typescript'] }) cli.injectPrompt({ name: 'useTsWithBabel', when: answers => answers.features.includes('ts'), type: 'confirm', message: 'Use Babel alongside TypeScript for auto-detected polyfills?', description: 'It will output ES2015 and delegate the rest to Babel for auto polyfill based on browser targets.', default: answers => answers.features.includes('babel') }) cli.onPromptComplete((answers, options) => { if (answers.features.includes('ts')) { const tsOptions = {} if (answers.eslintConfig === 'tslint') { tsOptions.tsLint = true tsOptions.lintOn = answers.lintOn } if (answers.useTsWithBabel) { tsOptions.useTsWithBabel = true } options.plugins['jslib-plugin-typescript'] = tsOptions } }) }