diff --git a/commands/exporter.js b/commands/exporter.js index 715da04..bcacfe5 100644 --- a/commands/exporter.js +++ b/commands/exporter.js @@ -28,13 +28,6 @@ exports.builder = { async function exporter(directory, flotiqApiUrl, flotiqApiKey, skipContent, ctd) { try { - const dirStat = await fs.lstat(directory); - - if (!dirStat.isDirectory()) { - logger.error(`${directory} exists, but isn't directory`); - return false; - } - const files = await fs.readdir(directory); if (files.length > 0) { @@ -135,6 +128,14 @@ async function exporter(directory, flotiqApiUrl, flotiqApiKey, skipContent, ctd) return true; } async function main(argv) { + + const dirStat = await fs.lstat(argv.directory); + + if (!dirStat.isDirectory()) { + logger.error(`${argv.directory} exists, but isn't directory`); + return false; + } + await exporter( argv.directory, `${config.apiUrl}/api/v1`, diff --git a/commands/importer.js b/commands/importer.js index 89e6780..904a5ea 100644 --- a/commands/importer.js +++ b/commands/importer.js @@ -96,10 +96,7 @@ async function checkIfClear(flotiqApiUrl, headers, CTDs) { return true } -async function importer(directory, flotiqApiUrl, flotiqApiKey, skipDefinitions, skipContent, updateDefinitions, disableWebhooks, fixDefinitions, - ctd, - skipCtd, - batch) +async function importer(directory, flotiqApiUrl, flotiqApiKey, skipDefinitions, skipContent, updateDefinitions, disableWebhooks, fixDefinitions, ctd, skipCtd, batch) { if (fixDefinitions) { updateDefinitions = true; @@ -115,11 +112,6 @@ async function importer(directory, flotiqApiUrl, flotiqApiKey, skipDefinitions, batchSize: BATCH_SIZE, }); - if (!directory || !flotiqApiUrl || !flotiqApiKey) { - console.error(`Usage: ${__filename} `) - return false; - } - try { await fs.stat(path.resolve(directory)) @@ -464,6 +456,11 @@ async function importer(directory, flotiqApiUrl, flotiqApiKey, skipDefinitions, } } async function main(argv) { + if (!argv.directory || !argv.flotiqApiKey) { + console.error(`Usage: ${__filename} `) + return false; + } + await importer( argv.directory, `${config.apiUrl}/api/v1`,