diff --git a/e2e/nx-run/src/cache.test.ts b/e2e/nx-run/src/cache.test.ts index 12ea5006ed3e03..d1ae7642d69ecd 100644 --- a/e2e/nx-run/src/cache.test.ts +++ b/e2e/nx-run/src/cache.test.ts @@ -68,12 +68,7 @@ describe('cache', () => { 'read the output from the cache' ); - if (process.platform != 'linux') { - // TODO(vsavkin): This should be always be matched output once you fix output watching on linux - expectMatchedOutput(outputWithBuildApp2Cached, [myapp2]); - } else { - expectCached(outputWithBuildApp2Cached, [myapp2]); - } + expectCached(outputWithBuildApp2Cached, [myapp2]); // touch package.json // -------------------------------------------- diff --git a/packages/nx/src/hasher/file-hasher.ts b/packages/nx/src/hasher/file-hasher.ts index 8c5a8936e5fd0d..73b1ed25b7e1cf 100644 --- a/packages/nx/src/hasher/file-hasher.ts +++ b/packages/nx/src/hasher/file-hasher.ts @@ -89,3 +89,15 @@ export function hashArray(content: string[]): string { const { hashArray } = require('../native'); return hashArray(content); } + +export function hashObject(obj: object): string { + const { hashArray } = require('../native'); + const parts: string[] = []; + + for (const key of Object.keys(obj).sort()) { + parts.push(key); + parts.push(JSON.stringify(obj[key])); + } + + return hashArray(parts); +} diff --git a/packages/nx/src/hasher/task-hasher.ts b/packages/nx/src/hasher/task-hasher.ts index 64c3526b6c1c52..e4672ca5b22306 100644 --- a/packages/nx/src/hasher/task-hasher.ts +++ b/packages/nx/src/hasher/task-hasher.ts @@ -14,7 +14,7 @@ import { hashTsConfig } from '../plugins/js/hasher/hasher'; import { DaemonClient } from '../daemon/client/client'; import { createProjectRootMappings } from '../project-graph/utils/find-project-for-path'; import { findMatchingProjects } from '../utils/find-matching-projects'; -import { FileHasher, hashArray } from './file-hasher'; +import { FileHasher, hashArray, hashObject } from './file-hasher'; import { getOutputsForTargetAndConfiguration } from '../tasks-runner/utils'; import { getHashEnv } from './set-hash-env'; import { workspaceRoot } from '../utils/workspace-root'; @@ -539,7 +539,7 @@ class TaskHasherImpl { if (this.allExternalDependenciesHash) { return this.allExternalDependenciesHash; } else { - hash = hashArray([JSON.stringify(this.projectGraph.externalNodes)]); + hash = hashObject(this.projectGraph.externalNodes); this.allExternalDependenciesHash = { value: hash, details: {