mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 21:24:26 +08:00
Move the last bits from the old tree structure and don't use the `test/unittests/` folder from now on. Fixed: b:325903709, b:323795674 Doc: http://go/chrome-devtools:move-unit-tests-design Change-Id: I47d727348d115d07f6b04b818359940c4361109a Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5332214 Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Auto-Submit: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import {readFileSync} from 'fs';
|
|
import {join} from 'path';
|
|
|
|
const isDebug = /^\s*is_debug\s*=\s*(.*)/;
|
|
|
|
/**
|
|
* Tests the args.gn file to ensure that the is_debug flag is set to true.
|
|
* We don't cover every case here, for example where is_debug is redefined
|
|
* in the gn.args several times. Instead we use the first declaration of
|
|
* is_debug's value.
|
|
*/
|
|
export function debugCheck(dirName: string): boolean {
|
|
const argsFile = join(dirName, '..', '..', 'args.gn');
|
|
try {
|
|
const fileDetails = readFileSync(argsFile, {encoding: 'utf8'});
|
|
for (const line of fileDetails.split('\n')) {
|
|
if (!isDebug.test(line)) {
|
|
continue;
|
|
}
|
|
|
|
const matches = isDebug.exec(line);
|
|
// For any match we expect:
|
|
// 0: the whole line
|
|
// 1: the value itself
|
|
if (!matches || matches.length < 2) {
|
|
return false;
|
|
}
|
|
|
|
const value = matches[1].toLowerCase();
|
|
if (value === 'true' || value === '1') {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
// By default, a DevTools build is always a debug build,
|
|
// unless `is_debug` is explicitly set to false
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|