(name)
| 163 | } |
| 164 | |
| 165 | export async function loadBuild(name) { |
| 166 | let dir = buildPath(name); |
| 167 | let manifest; |
| 168 | try { |
| 169 | manifest = JSON.parse(await fs.readFile(path.join(dir, 'manifest.json'), 'utf8')); |
| 170 | } catch (error) { |
| 171 | if (error.code === 'ENOENT') { |
| 172 | throw new Error( |
| 173 | `No snapshot named ${name}. Create it with \`yarn perf build --name ${name}\`.` |
| 174 | ); |
| 175 | } |
| 176 | throw error; |
| 177 | } |
| 178 | if ( |
| 179 | manifest.schema !== 1 || |
| 180 | !manifest.production || |
| 181 | manifest.harnessHash !== (await harnessHash()) |
| 182 | ) { |
| 183 | throw new Error( |
| 184 | `Snapshot ${name} uses a different harness or is not a verified production build. Rebuild both snapshots with the current harness.` |
| 185 | ); |
| 186 | } |
| 187 | if (manifest.artifactHash !== (await artifactHash(dir))) { |
| 188 | throw new Error(`Snapshot ${name} has been modified since it was built.`); |
| 189 | } |
| 190 | return manifest; |
| 191 | } |
no test coverage detected