Skip to content

Commit

Permalink
Revert "fix(core): store relative file name in hash details (#10166)"
Browse files Browse the repository at this point in the history
This reverts commit 5c9abff.
  • Loading branch information
vsavkin committed Jun 7, 2022
1 parent 48e4ece commit 6c3ce13
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 41 deletions.
30 changes: 0 additions & 30 deletions .husky/_/husky.sh

This file was deleted.

5 changes: 0 additions & 5 deletions packages/nx/src/hasher/hasher.spec.ts
@@ -1,6 +1,5 @@
// This must come before the Hasher import
import { DependencyType } from '../config/project-graph';
import { defaultFileHasher } from '../hasher/file-hasher';

jest.doMock('../utils/workspace-root', () => {
return {
Expand Down Expand Up @@ -57,10 +56,6 @@ describe('Hasher', () => {
}

beforeAll(() => {
jest
.spyOn(defaultFileHasher, 'hashFile')
.mockImplementation((p) => hashes[p]);

fs.readFileSync = (file) => {
if (file === 'workspace.json') {
return JSON.stringify(workSpaceJson);
Expand Down
21 changes: 15 additions & 6 deletions packages/nx/src/hasher/hasher.ts
Expand Up @@ -2,7 +2,7 @@ import { resolveNewFormatWithInlineProjects } from '../config/workspaces';
import { exec } from 'child_process';
import { existsSync } from 'fs';
import * as minimatch from 'minimatch';
import { join, sep as pathSep } from 'path';
import { join } from 'path';
import { performance } from 'perf_hooks';
import { getRootTsConfigFileName } from '../utils/typescript';
import { workspaceRoot } from '../utils/workspace-root';
Expand All @@ -13,7 +13,6 @@ import { NxJsonConfiguration } from '../config/nx-json';
import { Task } from '../config/task-graph';
import { readJsonFile } from '../utils/fileutils';
import { ProjectsConfigurations } from '../config/workspace-json-project-json';
import { defaultFileHasher } from './file-hasher';

/**
* A data structure returned by the default hasher.
Expand Down Expand Up @@ -249,10 +248,20 @@ export class Hasher {
];

const fileHashes = [
...fileNames.map((file) => ({
file,
hash: defaultFileHasher.hashFile(file),
})),
...fileNames
.map((maybeRelativePath) => {
// Normalize the path to always be absolute and starting with workspaceRoot so we can check it exists
if (!maybeRelativePath.startsWith(workspaceRoot)) {
return join(workspaceRoot, maybeRelativePath);
}
return maybeRelativePath;
})
.filter((file) => existsSync(file))
.map((file) => {
// we should use default file hasher here
const hash = this.hashing.hashFile(file);
return { file, hash };
}),
...this.hashNxJson(),
];

Expand Down

1 comment on commit 6c3ce13

@vercel
Copy link

@vercel vercel bot commented on 6c3ce13 Jun 7, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app
nx-five.vercel.app

Please sign in to comment.