-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add native extension implementation
This reverts commit b30c9fd.
- Loading branch information
1 parent
c7c5bc3
commit 4e7bdda
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FileHasherBase } from './file-hasher-base'; | ||
import { performance } from 'perf_hooks'; | ||
import { hashFile, hashFiles } from '@nrwl/native-extensions'; | ||
import { workspaceRoot } from '../utils/app-root'; | ||
|
||
export class NativeFileHasher extends FileHasherBase { | ||
async init(): Promise<void> { | ||
performance.mark('init hashing:start'); | ||
this.clear(); | ||
const filesObject = hashFiles(workspaceRoot); | ||
this.fileHashes = new Map(Object.entries(filesObject)); | ||
|
||
performance.mark('init hashing:end'); | ||
performance.measure( | ||
'init hashing', | ||
'init hashing:start', | ||
'init hashing:end' | ||
); | ||
} | ||
|
||
async hashFiles(files: string[]): Promise<Map<string, string>> { | ||
const r = new Map<string, string>(); | ||
|
||
for (let f of files) { | ||
r.set(f, this.hashFile(f)); | ||
} | ||
|
||
return r; | ||
} | ||
|
||
hashFile(path: string): string { | ||
return hashFile(path).hash; | ||
} | ||
} |