Skip to content

Commit 380269e

Browse files
committed
feat: add mode option for testing
1 parent 3d4b742 commit 380269e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

bin/commands/test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ exports.builder = (yargs) => yargs
1818
})
1919
.option('sha', {
2020
desc: 'Test against a specific commit or branch',
21-
type: 'string'
21+
type: 'string'})
22+
.option('mode', {
23+
desc: 'Choose the mode in which the package will be tested',
24+
type: 'string',
25+
choices: ['download', 'pull-request'],
26+
default: 'pull-request'
2227
})
2328
.option('config', {
2429
desc: 'Path to the configuration file. By default it will try to load the configuration from the first file it finds in the current working directory: `.wiby.json`, `.wiby.js`',
@@ -28,7 +33,7 @@ exports.builder = (yargs) => yargs
2833
exports.handler = (params) => {
2934
const config = params.dependent
3035
? {
31-
dependents: [{ repository: params.dependent, pullRequest: !!params['pull-request'], sha: params.sha || 'HEAD' }]
36+
dependents: [{ repository: params.dependent, pullRequest: !!params['pull-request'], sha: params.sha || 'HEAD', mode: params.mode || 'pull-request' }]
3237
}
3338
: wiby.validate({ config: params.config })
3439

lib/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const dependentSchema = joi.object({
1515
]
1616
}),
1717
pullRequest: joi.boolean().optional(),
18-
sha: joi.string().optional().default('HEAD')
18+
sha: joi.string().optional().default('HEAD'),
19+
mode: joi.string().valid('pull-request', 'download').optional().default('pull-request')
1920
}).unknown(false)
2021

2122
exports.schema = joi.object({

test/config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,20 @@ tap.test('config validation', async (tap) => {
3636
{
3737
repository: 'https://github.com/wiby-test/partial',
3838
pullRequest: false,
39-
sha: 'HEAD'
39+
sha: 'HEAD',
40+
mode: "pull-request"
4041
},
4142
{
4243
repository: 'git://github.com/wiby-test/fail',
4344
pullRequest: false,
44-
sha: 'HEAD'
45+
sha: 'HEAD',
46+
mode: "pull-request"
4547
},
4648
{
4749
repository: 'git+https://github.com/wiby-test/pass',
4850
pullRequest: true,
49-
sha: 'HEAD'
51+
sha: 'HEAD',
52+
mode: "pull-request"
5053
}
5154
]
5255
})

0 commit comments

Comments
 (0)