Skip to content

Commit

Permalink
Handle walk errors
Browse files Browse the repository at this point in the history
  • Loading branch information
camden11 committed Nov 28, 2023
1 parent 1095b70 commit 27828a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/cli/commands/cms/convertFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
} = require('@hubspot/cli-lib/lib/handleFieldsJs');

const { trackConvertFieldsUsage } = require('../../lib/usageTracking');
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
const i18nKey = 'cli.commands.convertFields';

exports.command = 'convert-fields';
Expand Down Expand Up @@ -54,7 +55,12 @@ exports.handler = async options => {
if (fieldsJs.rejected) return;
fieldsJs.saveOutput();
} else if (stats.isDirectory()) {
const filePaths = await walk(src);
let filePaths = [];
try {
filePaths = await walk(src);
} catch (e) {
logErrorInstance(e);
}
const allowedFilePaths = filePaths
.filter(file => {
if (!isAllowedExtension(file)) {
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/lib/projectStructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs');
const path = require('path');
const { walk } = require('@hubspot/local-dev-lib/fs');
const { logger } = require('@hubspot/cli-lib/logger');
const { logErrorInstance } = require('./errorHandlers/standardErrors');

const COMPONENT_TYPES = Object.freeze({
app: 'app',
Expand Down Expand Up @@ -73,8 +74,13 @@ function getIsLegacyApp(appConfig, appPath) {

async function findProjectComponents(projectSourceDir) {
const components = [];
let projectFiles = [];

const projectFiles = await walk(projectSourceDir);
try {
projectFiles = await walk(projectSourceDir);
} catch (e) {
logErrorInstance(e);
}

projectFiles.forEach(projectFile => {
// Find app components
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/lib/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ const { createIgnoreFilter } = require('@hubspot/local-dev-lib/ignoreRules');
const { fieldsJsPrompt } = require('../lib/prompts/cmsFieldPrompt');
const { isAllowedExtension } = require('@hubspot/cli-lib/path');
const { isConvertableFieldJs } = require('@hubspot/cli-lib/lib/handleFieldsJs');
const { logErrorInstance } = require('./errorHandlers/standardErrors');

/*
* Walks the src folder for files, filters them based on ignore filter.
* If convertFields is true then will check for any JS fields conflicts (i.e., JS fields file and fields.json file) and prompt to resolve
*/
const getUploadableFileList = async (src, convertFields) => {
const filePaths = await walk(src);
let filePaths = [];
try {
filePaths = await walk(src);
} catch (e) {
logErrorInstance(e);
}
const allowedFiles = filePaths
.filter(file => {
if (!isAllowedExtension(file)) {
Expand Down

0 comments on commit 27828a2

Please sign in to comment.