mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +00:00
fix option validation and order
This commit is contained in:
parent
e404bc6015
commit
ac4e688995
@ -296,6 +296,14 @@ program
|
||||
.addOption(excludeOption)
|
||||
.addOption(onlyOption)
|
||||
.hook('preAction', validateExcludeOnly)
|
||||
.hook(
|
||||
'preAction',
|
||||
ifOptions(
|
||||
(opts) => !(opts.from || opts.to) || (opts.from && opts.to),
|
||||
() =>
|
||||
exitWith(1, 'Exactly one remote source (from) or destination (to) option must be provided')
|
||||
)
|
||||
)
|
||||
// If --from is used, validate the URL and token
|
||||
.hook(
|
||||
'preAction',
|
||||
@ -346,21 +354,6 @@ program
|
||||
}
|
||||
)
|
||||
)
|
||||
.hook(
|
||||
'preAction',
|
||||
ifOptions(
|
||||
(opts) => !opts.from && !opts.to,
|
||||
() =>
|
||||
exitWith(1, 'At least one remote source (from) or destination (to) option must be provided')
|
||||
)
|
||||
)
|
||||
.hook(
|
||||
'preAction',
|
||||
ifOptions(
|
||||
(opts) => opts.from && opts.to,
|
||||
() => exitWith(1, 'Only one source (from) or destination (to) option may be provided')
|
||||
)
|
||||
)
|
||||
.action(getLocalScript('transfer/transfer'));
|
||||
|
||||
// `$ strapi export`
|
||||
|
||||
@ -35,6 +35,9 @@ describe('Transfer', () => {
|
||||
strapi: {
|
||||
providers: {
|
||||
createLocalStrapiSourceProvider: jest.fn().mockReturnValue({ name: 'testLocalSource' }),
|
||||
createLocalStrapiDestinationProvider: jest
|
||||
.fn()
|
||||
.mockReturnValue({ name: 'testLocalDestination' }),
|
||||
createRemoteStrapiDestinationProvider: jest
|
||||
.fn()
|
||||
.mockReturnValue({ name: 'testRemoteDest' }),
|
||||
|
||||
@ -44,8 +44,13 @@ module.exports = async (opts) => {
|
||||
exitWith(1, 'Could not parse command arguments');
|
||||
}
|
||||
|
||||
const strapi = await createStrapiInstance();
|
||||
if (!(opts.from || opts.to) || (opts.from && opts.to)) {
|
||||
console.log('from', opts.from);
|
||||
console.log('to', opts.to);
|
||||
exitWith(1, 'Exactly one source (from) or destination (to) option must be provided');
|
||||
}
|
||||
|
||||
const strapi = await createStrapiInstance();
|
||||
let source;
|
||||
let destination;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user