-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f2b9aa
commit 3c113db
Showing
16 changed files
with
159 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
const t = require('tap') | ||
const { setup: _setup, child, isChild } = require('./fixtures/setup') | ||
|
||
if (isChild()) { | ||
return child(__filename) | ||
} | ||
|
||
const setup = (...args) => _setup(__filename, args).then(JSON.parse) | ||
|
||
t.test('conditional', async (t) => { | ||
t.same(await setup(''), {}) | ||
t.same(await setup('a'), {}) | ||
t.same(await setup('git', ''), {}) | ||
t.same(await setup('git', 'http'), { | ||
repository: { | ||
type: 'git', | ||
url: 'http', | ||
}, | ||
}) | ||
t.same(await setup('svn', 'http'), { | ||
repository: { | ||
type: 'svn', | ||
url: 'http', | ||
}, | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const t = require('tap') | ||
const { setup, child, isChild } = require('./fixtures/setup') | ||
|
||
if (isChild()) { | ||
return child('file does not exist') | ||
} | ||
|
||
t.test('backup file', async (t) => { | ||
t.match(await setup(__filename), 'ENOENT') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* globals prompt */ | ||
|
||
module.exports = { | ||
repository: { | ||
type: prompt('repo type'), | ||
url () { | ||
if (['git', 'svn'].includes(this.res.repository.type)) { | ||
return prompt(`${this.res.repository.type} url`) | ||
} | ||
}, | ||
}, | ||
// this name of this doesnt matter, just that it comes last | ||
'' () { | ||
if (!this.res.repository.type || !this.res.repository.url) { | ||
delete this.res.repository | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* globals prompt */ | ||
|
||
const transform = (a) => a | ||
|
||
module.exports = { | ||
a: prompt({ | ||
prompt: 'a', | ||
default: 'a', | ||
transform, | ||
}), | ||
b: prompt('b', 'b', () => 'b', { | ||
prompt: 'a', | ||
default: 'a', | ||
transform, | ||
}), | ||
c: prompt('c', 'c', transform, {}), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const t = require('tap') | ||
const { setup, child, isChild } = require('./fixtures/setup') | ||
|
||
if (isChild()) { | ||
return child(__filename) | ||
} | ||
|
||
t.test('prompts', async (t) => { | ||
const output = await setup(__filename, ['', '', '']) | ||
|
||
t.same(JSON.parse(output), { | ||
a: 'a', | ||
b: 'a', | ||
c: 'c', | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
const t = require('tap') | ||
const { setup, child, isChild } = require('./fixtures/setup') | ||
const { setup: _setup, child, isChild } = require('./fixtures/setup') | ||
|
||
if (isChild()) { | ||
return child(__filename, { tmpdir: '/tmp' }) | ||
} | ||
|
||
t.test('simple', async (t) => { | ||
const output = await setup(__filename, ['', '55']) | ||
const setup = (...args) => _setup(__filename, args) | ||
|
||
t.same(JSON.parse(output), { | ||
t.test('simple', async (t) => { | ||
t.same(await setup('', '55', 'no error').then(JSON.parse), { | ||
a: 3, | ||
b: '!2b', | ||
c: { | ||
x: 55, | ||
y: '/tmp/y/file.txt', | ||
}, | ||
error: 'no error', | ||
}) | ||
|
||
t.match(await setup('', '55', 'throw'), /Error: this is unexpected/) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters