Merge pull request #52 from zachwolf/optional-git
Adds ability to conditionally create a git repo
This commit is contained in:
parent
534eb109e9
commit
fd11c17b98
4 changed files with 34 additions and 12 deletions
|
@ -15,8 +15,9 @@ module.exports = async (info) => {
|
|||
const {
|
||||
manager,
|
||||
template,
|
||||
name,
|
||||
templatePath,
|
||||
name
|
||||
git
|
||||
} = info
|
||||
|
||||
// handle scoped package names
|
||||
|
@ -53,7 +54,7 @@ module.exports = async (info) => {
|
|||
await promise
|
||||
}
|
||||
|
||||
{
|
||||
if (git) {
|
||||
const promise = module.exports.initGitRepo({ dest })
|
||||
ora.promise(promise, 'Initializing git repo')
|
||||
await promise
|
||||
|
|
|
@ -15,7 +15,8 @@ const tests = [
|
|||
repo: 'nala/my-test-library',
|
||||
license: 'MIT',
|
||||
manager: 'yarn',
|
||||
template: 'default'
|
||||
template: 'default',
|
||||
git: true
|
||||
},
|
||||
{
|
||||
name: 'my-test-typescript-library',
|
||||
|
@ -24,7 +25,8 @@ const tests = [
|
|||
repo: 'nala/my-test-library',
|
||||
license: 'MIT',
|
||||
manager: 'yarn',
|
||||
template: 'typescript'
|
||||
template: 'typescript',
|
||||
git: true
|
||||
},
|
||||
{
|
||||
name: 'my-test-library',
|
||||
|
@ -33,7 +35,8 @@ const tests = [
|
|||
repo: 'nala/my-test-library',
|
||||
license: 'MIT',
|
||||
manager: 'npm',
|
||||
template: 'default'
|
||||
template: 'default',
|
||||
git: true
|
||||
},
|
||||
{
|
||||
name: 'my-test-library',
|
||||
|
@ -42,7 +45,8 @@ const tests = [
|
|||
repo: 'nala/my-test-typescript-library',
|
||||
license: 'MIT',
|
||||
manager: 'npm',
|
||||
template: 'typescript'
|
||||
template: 'typescript',
|
||||
git: true
|
||||
},
|
||||
{
|
||||
name: '@automagical/nala',
|
||||
|
@ -51,7 +55,18 @@ const tests = [
|
|||
repo: 'superstar-cats/nala',
|
||||
license: 'GPL',
|
||||
manager: 'yarn',
|
||||
template: 'default'
|
||||
template: 'default',
|
||||
git: true
|
||||
},
|
||||
{
|
||||
name: 'no-git-library',
|
||||
author: 'nala',
|
||||
description: 'this is a auto-generated test module. please ignore.',
|
||||
repo: 'nala/no-git-library',
|
||||
license: 'MIT',
|
||||
manager: 'yarn',
|
||||
template: 'default',
|
||||
git: false
|
||||
},
|
||||
{
|
||||
name: 'my-custom-template',
|
||||
|
@ -61,7 +76,8 @@ const tests = [
|
|||
license: 'GPL',
|
||||
manager: 'yarn',
|
||||
template: 'custom',
|
||||
templatePath: './template/default'
|
||||
templatePath: './template/default',
|
||||
git: true
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -92,8 +108,8 @@ tests.forEach((opts) => {
|
|||
t.is(ret.code, 0)
|
||||
|
||||
// ensure git is initialized properly
|
||||
ret = await execa.shell('git status', { cwd: root })
|
||||
t.is(ret.code, 0)
|
||||
ret = await execa.shell('git rev-parse --git-dir', { cwd: root })
|
||||
t.is(ret.stdout, opts.git ? '.git' : path.join(process.cwd(), '.git'))
|
||||
|
||||
await rmfr(root)
|
||||
})
|
||||
|
|
|
@ -20,6 +20,7 @@ module.exports = async () => {
|
|||
.option('-a, --author <string>', 'author\'s github handle', defaults.author)
|
||||
.option('-l, --license <string>', 'package license', defaults.license)
|
||||
.option('-r, --repo <string>', 'package repo path')
|
||||
.option('-g, --no-git', 'generate without git init')
|
||||
.option('-m, --manager <npm|yarn>', 'package manager to use', /^(npm|yarn)$/, defaults.manager)
|
||||
.option('-t, --template <default|typescript>', 'package template to use', /^(default|typescript|custom)$/, defaults.template)
|
||||
.option('-p, --template-path <string>', 'custom package template path')
|
||||
|
@ -33,7 +34,8 @@ module.exports = async () => {
|
|||
repo: program.repo,
|
||||
manager: program.manager,
|
||||
template: program.template,
|
||||
skipPrompts: program.skipPrompts
|
||||
skipPrompts: program.skipPrompts,
|
||||
git: program.git
|
||||
}
|
||||
|
||||
Object.keys(opts).forEach((key) => {
|
||||
|
|
|
@ -96,6 +96,9 @@ module.exports = async (opts) => {
|
|||
config.set('manager', info.manager)
|
||||
config.set('template', info.template)
|
||||
|
||||
return info
|
||||
return {
|
||||
...info,
|
||||
git: opts.git
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue