mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 17:27:22 +08:00
This updates karma to 5.2.3, karma-coverage to the officially published version 2.0.3 (we were previously relying on a git commit) and karma-sourcemap-loader to 0.3.8. DISABLE_THIRD_PARTY_CHECK=Update Karma R=aerotwist@chromium.org Change-Id: Iaa365379d7c2c6eb9145b1507be1a0a3ae812359 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2527043 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Paul Lewis <aerotwist@chromium.org> Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
const browserify = require('browserify')
|
|
const fs = require('fs')
|
|
const { readFile } = require('fs').promises
|
|
|
|
const bundleResourceToFile = (inPath, outPath) => {
|
|
return new Promise((resolve, reject) => {
|
|
browserify(inPath).bundle()
|
|
.pipe(fs.createWriteStream(outPath))
|
|
.once('finish', () => resolve())
|
|
.once('error', (e) => reject(e))
|
|
})
|
|
}
|
|
|
|
const bundleResource = (inPath) => {
|
|
return new Promise((resolve, reject) => {
|
|
browserify(inPath).bundle((err, buffer) => {
|
|
if (err != null) {
|
|
reject(err)
|
|
return
|
|
}
|
|
|
|
resolve(buffer)
|
|
})
|
|
})
|
|
}
|
|
|
|
const main = async () => {
|
|
if (process.argv[2] === 'build') {
|
|
await bundleResourceToFile('client/main.js', 'static/karma.js')
|
|
await bundleResourceToFile('context/main.js', 'static/context.js')
|
|
} else if (process.argv[2] === 'check') {
|
|
const expectedClient = await bundleResource('client/main.js')
|
|
const expectedContext = await bundleResource('context/main.js')
|
|
|
|
const actualClient = await readFile('static/karma.js')
|
|
const actualContext = await readFile('static/context.js')
|
|
|
|
if (Buffer.compare(expectedClient, actualClient) !== 0 || Buffer.compare(expectedContext, actualContext) !== 0) {
|
|
// eslint-disable-next-line no-throw-literal
|
|
throw 'Bundled client assets are outdated. Forgot to run "npm run build"?'
|
|
}
|
|
} else {
|
|
// eslint-disable-next-line no-throw-literal
|
|
throw `Unknown command: ${process.argv[2]}`
|
|
}
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|