Skip to content

Commit

Permalink
fix bugs with fetch commands
Browse files Browse the repository at this point in the history
  • Loading branch information
camden11 committed Jan 12, 2024
1 parent ecd7c02 commit 96ccb61
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 21 deletions.
29 changes: 19 additions & 10 deletions packages/cli/commands/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ const { i18n } = require('../lib/lang');
const i18nKey = 'cli.commands.fetch';
const { EXIT_CODES } = require('../lib/enums/exitCodes');
const { buildLogCallbacks } = require('../lib/logCallbacks');
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');

const fileMapperLogCallbacks = buildLogCallbacks({
skippedExisting: `${i18nKey}.fileMapperLogCallbacks.skippedExisting`,
wroteFolder: `${i18nKey}.fileMapperLogCallbacks.wroteFolder`,
completedFetch: `${i18nKey}.fileMapperLogCallbacks.completedFetch`,
completedFetch: {
key: `${i18nKey}.fileMapperLogCallbacks.completedFetch`,
type: 'success',
},
folderFetch: `${i18nKey}.fileMapperLogCallbacks.folderFetch`,
completedFolderFetch: {
key: `${i18nKey}.fileMapperLogCallbacks.completedFolderFetch`,
Expand Down Expand Up @@ -52,15 +56,20 @@ exports.handler = async options => {

trackCommandUsage('fetch', { mode }, accountId);

// Fetch and write file/folder.
downloadFileOrFolder(
accountId,
src,
resolveLocalPath(dest),
mode,
options,
fileMapperLogCallbacks
);
try {
// Fetch and write file/folder.
await downloadFileOrFolder(
accountId,
src,
resolveLocalPath(dest),
mode,
options,
fileMapperLogCallbacks
);
} catch (err) {
logErrorInstance(err);
process.exit(EXIT_CODES.ERROR);
}
};

exports.builder = yargs => {
Expand Down
34 changes: 23 additions & 11 deletions packages/cli/commands/filemanager/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ const { i18n } = require('../../lib/lang');

const i18nKey = 'cli.commands.filemanager.subcommands.fetch';
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');

const downloadLogCallbacks = buildLogCallbacks({
skippedExisting: `${i18nKey}.downloadLogCallbacks.skippedExisting`,
fetchFolderStarted: `${i18nKey}.downloadLogCallbacks.fetchFolderStarted`,
fetchFolderSuccess: `${i18nKey}.downloadLogCallbacks.fetchFolderSuccess`,
fetchFolderSuccess: {
key: `${i18nKey}.downloadLogCallbacks.fetchFolderSuccess`,
type: 'success',
},
fetchFileStarted: `${i18nKey}.downloadLogCallbacks.fetchFileStarted`,
fetchFileSuccess: `${i18nKey}.downloadLogCallbacks.fetchFileSuccess`,
fetchFileSuccess: {
key: `${i18nKey}.downloadLogCallbacks.fetchFileSuccess`,
type: 'success',
},
});

exports.command = 'fetch <src> [dest]';
Expand All @@ -43,15 +50,20 @@ exports.handler = async options => {

trackCommandUsage('filemanager-fetch', null, accountId);

// Fetch and write file/folder.
await downloadFileOrFolder(
accountId,
src,
dest,
false,
includeArchived || false,
downloadLogCallbacks
);
try {
// Fetch and write file/folder.
await downloadFileOrFolder(
accountId,
src,
dest,
false,
includeArchived || false,
downloadLogCallbacks
);
} catch (err) {
logErrorInstance(err);
process.exit(EXIT_CODES.ERROR);
}
};

exports.builder = yargs => {
Expand Down

0 comments on commit 96ccb61

Please sign in to comment.