Merge pull request #94 from bmuenzenmeyer/93-template-path
fix(templatePath): supply templatePath if specified as default to inquirer
This commit is contained in:
parent
39c4e570d2
commit
7f7dd1d739
3 changed files with 27 additions and 0 deletions
|
@ -35,6 +35,7 @@ module.exports = async () => {
|
||||||
repo: program.repo,
|
repo: program.repo,
|
||||||
manager: program.manager,
|
manager: program.manager,
|
||||||
template: program.template,
|
template: program.template,
|
||||||
|
templatePath: program.templatePath,
|
||||||
skipPrompts: program.skipPrompts,
|
skipPrompts: program.skipPrompts,
|
||||||
git: program.git
|
git: program.git
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ module.exports = async (opts) => {
|
||||||
type: 'input',
|
type: 'input',
|
||||||
name: 'templatePath',
|
name: 'templatePath',
|
||||||
message: 'Template Path',
|
message: 'Template Path',
|
||||||
|
default: opts.templatePath,
|
||||||
when: ({ template }) => template === 'custom',
|
when: ({ template }) => template === 'custom',
|
||||||
validate: input => new Promise(resolve => {
|
validate: input => new Promise(resolve => {
|
||||||
const fullPath = path.resolve(process.cwd(), input)
|
const fullPath = path.resolve(process.cwd(), input)
|
||||||
|
|
|
@ -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]])
|
||||||
|
})
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue