Skip to content

Commit

Permalink
Clean up things, use i18n in buildLogCallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
camden11 committed Dec 4, 2023
1 parent 46e0acd commit 6661e30
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
11 changes: 9 additions & 2 deletions packages/cli/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const { handleExit } = require('../lib/process');
const {
checkAndAddConfigToGitignore,
} = require('@hubspot/local-dev-lib/gitignore');
const { logErrorInstance } = require('../lib/errorHandlers/standardErrors');
const {
logErrorInstance,
debugErrorAndContext,
} = require('../lib/errorHandlers/standardErrors');
const {
DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
PERSONAL_ACCESS_KEY_AUTH_METHOD,
Expand Down Expand Up @@ -119,7 +122,11 @@ exports.handler = async options => {
);
const configPath = getConfigPath();

checkAndAddConfigToGitignore(configPath);
try {
checkAndAddConfigToGitignore(configPath);
} catch (e) {
debugErrorAndContext(e);
}

logger.log('');
logger.success(
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/commands/project/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const i18nKey = 'cli.commands.project.subcommands.download';
const { EXIT_CODES } = require('../../lib/enums/exitCodes');

const archiveLogCallbacks = buildLogCallbacks({
init: 'Extracting project source...',
copy: 'Copying project source...',
init: `${i18nKey}.archiveLogCallbacks.init`,
copy: `${i18nKey}.archiveLogCallbacks.copy`,
});

exports.command = 'download [--project]';
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@ en:
describe: "The name of the project to download"
dest:
describe: "Destination folder for the project"
archiveLogCallbacks:
init: "Extracting project source..."
copy: "Copying project source..."
open:
describe: "Open the specified project's details page in the browser"
options:
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/lib/logCallbacks.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const { logger } = require('@hubspot/cli-lib/logger');
const { i18n } = require('./lang');

function buildLogCallbacks(logData) {
const callbacksObject = {};
for (let key in logData) {
callbacksObject[key] = () => logger.log(logData[key]);
callbacksObject[key] = () => logger.log(i18n(logData[key]));
}
return callbacksObject;
}
Expand Down

0 comments on commit 6661e30

Please sign in to comment.