1
0
Fork 0

Merge pull request #94 from bmuenzenmeyer/93-template-path

fix(templatePath): supply templatePath if specified as default to inquirer
This commit is contained in:
Travis Fischer 2018-10-28 23:50:50 -04:00 committed by Joost De Cock
parent 39c4e570d2
commit 7f7dd1d739
3 changed files with 27 additions and 0 deletions

View file

@ -35,6 +35,7 @@ module.exports = async () => {
repo: program.repo,
manager: program.manager,
template: program.template,
templatePath: program.templatePath,
skipPrompts: program.skipPrompts,
git: program.git
}

View file

@ -78,6 +78,7 @@ module.exports = async (opts) => {
type: 'input',
name: 'templatePath',
message: 'Template Path',
default: opts.templatePath,
when: ({ template }) => template === 'custom',
validate: input => new Promise(resolve => {
const fullPath = path.resolve(process.cwd(), input)

View file

@ -0,0 +1,25 @@
'use strict'
const { test } = require('ava')
const promptLibraryParams = require('./prompt-library-params')
const opts = {
name: 'my-custom-template',
author: 'nala',
description: 'this is a auto-generated test module. please ignore.',
repo: 'nala/my-custom-template',
license: 'GPL',
manager: 'yarn',
template: 'custom',
templatePath: './template/default',
git: true
}
test('passed options are returned when skipPrompts is true', async t => {
const result = await promptLibraryParams(Object.assign({}, opts, { skipPrompts: true }))
Object.entries(opts).forEach(opt => {
// console.log(`comparing passed in option ${opt[0]}:${opt[1]} to returned option ${result[opt[0]]}`)
t.is(opt[1], result[opt[0]])
})
})