Skip to content

Project watch: watch for deleted directories #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/cli-lib/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ en:
watching: "Watcher is ready and watching \"{{ projectDir }}\". Any changes detected will be automatically uploaded and added to the current staging build."
resuming: "Resuming watcher..."
uploadSucceeded: "Uploaded file \"{{ filePath }}\" to \"{{ remotePath }}\""
deleteSucceeded: "Deleted file \"{{ remotePath }}\""
deleteFileSucceeded: "Deleted file \"{{ remotePath }}\""
deleteFolderSucceeded: "Deleted folder \"{{ remotePath }}\""
createNewBuild: "Staging build #{{ buildId }} created"
buildCancelled: "Staging build has been cancelled. Please try running `hs project watch` again"
debug:
Expand All @@ -500,7 +501,8 @@ en:
errors:
projectLocked: "The previous staging build is still in progress"
uploadFailed: "Failed to upload file \"{{ filePath }}\" to \"{{ remotePath }}\""
deleteFailed: "Failed to delete file \"{{ remotePath }}\""
deleteFileFailed: "Failed to delete file \"{{ remotePath }}\""
deleteFolderFailed: "Failed to delete folder \"{{ remotePath }}\""
remove:
describe: "Delete a file or folder from HubSpot."
deleted: "Deleted \"{{ path }}\" from account {{ accountId }}"
Expand Down
15 changes: 12 additions & 3 deletions packages/cli-lib/projectsWatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const queueFileUpload = async (
remotePath,
action
) => {
if (!isAllowedExtension(filePath)) {
if (action === 'upload' && !isAllowedExtension(filePath)) {
logger.debug(i18n(`${i18nKey}.debug.extensionNotAllowed`, { filePath }));
return;
}
Expand All @@ -101,7 +101,7 @@ const queueFileUpload = async (
try {
if (action === 'upload') {
await uploadFileToBuild(accountId, projectName, filePath, remotePath);
} else if (action === 'delete') {
} else if (action === 'deleteFile' || action === 'deleteFolder') {
await deleteFileFromBuild(accountId, projectName, remotePath);
}
logger.log(
Expand Down Expand Up @@ -186,7 +186,16 @@ const createWatcher = async (
projectConfig.name,
projectSourceDir,
filePath,
'delete'
'deleteFile'
);
});
watcher.on('unlinkDir', async filePath => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of a nit, but should this arg be folderPath?

addFile(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but this func supports folders and also the "delete" action now. I wonder if we should change the name of it to be more generic.

accountId,
projectConfig.name,
projectSourceDir,
filePath,
'deleteFolder'
);
});
};
Expand Down