-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start livesync watcher before preparing the project
Implemented #3404
- Loading branch information
Showing
11 changed files
with
100 additions
and
26 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,4 @@ | ||
interface IFilesHashService { | ||
generateHashes(files: string[]): Promise<IStringDictionary>; | ||
getChanges(files: string[], oldHashes: IStringDictionary): Promise<IStringDictionary>; | ||
} |
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
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,26 @@ | ||
import { executeActionByChunks } from "../common/helpers"; | ||
import { DEFAULT_CHUNK_SIZE } from "../common/constants"; | ||
|
||
export class FilesHashService implements IFilesHashService { | ||
constructor(private $fs: IFileSystem) { } | ||
|
||
public async generateHashes(files: string[]): Promise<IStringDictionary> { | ||
const result: IStringDictionary = {}; | ||
|
||
const action = async (file: string) => { | ||
if (this.$fs.getFsStats(file).isFile()) { | ||
result[file] = await this.$fs.getFileShasum(file); | ||
} | ||
}; | ||
|
||
await executeActionByChunks(files, DEFAULT_CHUNK_SIZE, action); | ||
|
||
return result; | ||
} | ||
|
||
public async getChanges(files: string[], oldHashes: IStringDictionary): Promise<IStringDictionary> { | ||
const newHashes = await this.generateHashes(files); | ||
return _.omitBy(newHashes, (hash: string, pathToFile: string) => !!_.find(oldHashes, (oldHash: string, oldPath: string) => pathToFile === oldPath && hash === oldHash)); | ||
} | ||
} | ||
$injector.register("filesHashService", FilesHashService); |
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
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
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