1 |
|
2 |
|
3 |
|
4 | 'use strict';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function createSnapshot (fileDependencies, mainCompilation, startTime) {
|
13 | return new Promise((resolve, reject) => {
|
14 | mainCompilation.fileSystemInfo.createSnapshot(
|
15 | startTime,
|
16 | fileDependencies.fileDependencies,
|
17 | fileDependencies.contextDependencies,
|
18 | fileDependencies.missingDependencies,
|
19 | null,
|
20 | (err, snapshot) => {
|
21 | if (err) {
|
22 | return reject(err);
|
23 | }
|
24 | resolve(snapshot);
|
25 | }
|
26 | );
|
27 | });
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | function isSnapShotValid (snapshot, mainCompilation) {
|
39 | return new Promise((resolve, reject) => {
|
40 | mainCompilation.fileSystemInfo.checkSnapshotValid(
|
41 | snapshot,
|
42 | (err, isValid) => {
|
43 | if (err) {
|
44 | reject(err);
|
45 | }
|
46 | resolve(isValid);
|
47 | }
|
48 | );
|
49 | });
|
50 | }
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | function watchFiles (mainCompilation, fileDependencies) {
|
60 | Object.keys(fileDependencies).forEach((depencyTypes) => {
|
61 | fileDependencies[depencyTypes].forEach(fileDependency => {
|
62 | mainCompilation[depencyTypes].add(fileDependency);
|
63 | });
|
64 | });
|
65 | }
|
66 |
|
67 | module.exports = {
|
68 | createSnapshot,
|
69 | isSnapShotValid,
|
70 | watchFiles
|
71 | };
|