Skip to content

Commit

Permalink
fix(core): git hashing fails when trying to hash a dir
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Nov 27, 2021
1 parent 023d230 commit b6eb772
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/workspace/src/core/file-utils.ts
Expand Up @@ -333,6 +333,11 @@ export function updateProjectFileMap(
): { projectFileMap: ProjectFileMap; allWorkspaceFiles: FileData[] } {
const ignore = getIgnoredGlobs();
const sortedProjects = sortProjects(workspaceJson);
for (let projectName of sortedProjects) {
if (!projectFileMap[projectName]) {
projectFileMap[projectName] = [];
}
}

for (const f of updatedFiles.keys()) {
if (ignore.ignores(f)) continue;
Expand Down
Expand Up @@ -88,9 +88,6 @@ function processCollectedUpdatedAndDeletedFiles() {
appRootPath
);
const deletedFiles = [...collectedDeletedFiles.values()];
collectedUpdatedFiles.clear();
collectedDeletedFiles.clear();

performance.mark('hash-watched-changes-end');
performance.measure(
'hash changed files from watcher',
Expand Down Expand Up @@ -119,6 +116,9 @@ function processCollectedUpdatedAndDeletedFiles() {
)
: createProjectFileMap(workspaceJson);
}

collectedUpdatedFiles.clear();
collectedDeletedFiles.clear();
}

async function createAndSerializeProjectGraph() {
Expand Down
Expand Up @@ -26,6 +26,7 @@ import {
getCachedSerializedProjectGraphPromise,
resetInternalState,
} from './project-graph-incremental-recomputation';
import { statSync } from 'fs';

function respondToClient(socket: Socket, message: string) {
socket.write(message, () => {
Expand Down Expand Up @@ -228,7 +229,14 @@ const handleWorkspaceChanges: SubscribeToWorkspaceChangesCallback = async (
if (event.type === 'delete') {
deletedFiles.push(event.path);
} else {
filesToHash.push(event.path);
try {
const s = statSync(join(appRootPath, event.path));
if (!s.isDirectory()) {
filesToHash.push(event.path);
}
} catch (e) {
// this can happen when the update file was deleted right after
}
}
}
addUpdatedAndDeletedFiles(filesToHash, deletedFiles);
Expand Down

0 comments on commit b6eb772

Please sign in to comment.