Skip to content

Commit 6cbc146

Browse files
Merge pull request transitive-bullshit#94 from bmuenzenmeyer/93-template-path
fix(templatePath): supply templatePath if specified as default to inquirer
2 parents 016c63d + 547af72 commit 6cbc146

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module.exports = async () => {
3535
repo: program.repo,
3636
manager: program.manager,
3737
template: program.template,
38+
templatePath: program.templatePath,
3839
skipPrompts: program.skipPrompts,
3940
git: program.git
4041
}

lib/prompt-library-params.js

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ module.exports = async (opts) => {
7878
type: 'input',
7979
name: 'templatePath',
8080
message: 'Template Path',
81+
default: opts.templatePath,
8182
when: ({ template }) => template === 'custom',
8283
validate: input => new Promise(resolve => {
8384
const fullPath = path.resolve(process.cwd(), input)

lib/prompt-library-params.test.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict'
2+
3+
const { test } = require('ava')
4+
5+
const promptLibraryParams = require('./prompt-library-params')
6+
7+
const opts = {
8+
name: 'my-custom-template',
9+
author: 'nala',
10+
description: 'this is a auto-generated test module. please ignore.',
11+
repo: 'nala/my-custom-template',
12+
license: 'GPL',
13+
manager: 'yarn',
14+
template: 'custom',
15+
templatePath: './template/default',
16+
git: true
17+
}
18+
19+
test('passed options are returned when skipPrompts is true', async t => {
20+
const result = await promptLibraryParams(Object.assign({}, opts, { skipPrompts: true }))
21+
Object.entries(opts).forEach(opt => {
22+
// console.log(`comparing passed in option ${opt[0]}:${opt[1]} to returned option ${result[opt[0]]}`)
23+
t.is(opt[1], result[opt[0]])
24+
})
25+
})

0 commit comments

Comments
 (0)