mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 09:17:09 +08:00
The current Loc presubmit are doing two checks: check_localizable_resources and check_localizability (Details of what they are checking: https://docs.google.com/document/d/1L6TkT2-42MMQ72ZSBMFwUaq7M6mDgA2X0x8oHHKaV_U/edit#heading=h.w1no7qaa0mi0) This CL merge two checks into one single check. check_localizability are modified into a utils file, and check_localizable_resources will also run those localizability checks when the files are visited. By doing this, we avoid the extra call to node during presubmit, and all files and nodes will only be visited once. Also adding these fixes https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2370103 Fix: - Pass the fullpath for comparison.(itemPath) - Normalize comparison between paths - using native fs.promises instead of promisify (https://github.com/nodejs/node/pull/26581) Bug: 1116989 Change-Id: I054040d83a65b5f798a21c040096422e287bc799 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2381320 Reviewed-by: Vidal Diazleal <vidorteg@microsoft.com> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Christy Chen <chrche@microsoft.com>
114 lines
3.4 KiB
Python
114 lines
3.4 KiB
Python
# Copyright 2019 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.
|
|
"""
|
|
Helper to find the path to the correct third_party directory
|
|
"""
|
|
|
|
from os import path
|
|
import sys
|
|
import platform
|
|
|
|
|
|
# Find the root path of the checkout.
|
|
# In the Chromium repository, this is the src/chromium directory.
|
|
# In the external repository, standalone build, this is the devtools-frontend directory.
|
|
# In the external repository, integrated build, this is the src/chromium directory.
|
|
def root_path():
|
|
SCRIPTS_PATH = path.dirname(path.abspath(__file__))
|
|
ABS_DEVTOOLS_PATH = path.dirname(SCRIPTS_PATH)
|
|
PARENT_PATH = path.dirname(ABS_DEVTOOLS_PATH)
|
|
# TODO(1011259): remove Chromium repository handling
|
|
if path.basename(PARENT_PATH) == 'renderer':
|
|
# Chromium repository
|
|
return path.dirname(path.dirname(path.dirname(PARENT_PATH)))
|
|
elif path.basename(PARENT_PATH) == 'devtools-frontend':
|
|
# External repository, integrated build
|
|
return path.dirname(path.dirname(PARENT_PATH))
|
|
else:
|
|
# External repository, standalone build
|
|
return ABS_DEVTOOLS_PATH
|
|
|
|
|
|
# This is the third_party path relative to the root of the checkout.
|
|
def third_party_path():
|
|
return path.join(root_path(), 'third_party')
|
|
|
|
|
|
# This points to the node binary downloaded as part of the checkout.
|
|
def node_path():
|
|
try:
|
|
old_sys_path = sys.path[:]
|
|
sys.path.append(path.join(third_party_path(), 'node'))
|
|
import node
|
|
finally:
|
|
sys.path = old_sys_path
|
|
return node.GetBinaryPath()
|
|
|
|
|
|
def devtools_root_path():
|
|
return path.dirname((path.dirname(path.abspath(__file__))))
|
|
|
|
|
|
def node_modules_path():
|
|
return path.join(devtools_root_path(), 'node_modules')
|
|
|
|
|
|
def eslint_path():
|
|
return path.join(node_modules_path(), 'eslint', 'bin', 'eslint.js')
|
|
|
|
|
|
def mocha_path():
|
|
return path.join(node_modules_path(), 'mocha', 'bin', 'mocha')
|
|
|
|
|
|
def check_localizable_resources_path():
|
|
return path.join(devtools_root_path(), 'scripts', 'localization', 'check_localizable_resources.js')
|
|
|
|
|
|
def karma_path():
|
|
return path.join(node_modules_path(), 'karma', 'bin', 'karma')
|
|
|
|
|
|
def typescript_compiler_path():
|
|
return path.join(node_modules_path(), 'typescript', 'bin', 'tsc')
|
|
|
|
|
|
def hosted_mode_script_path():
|
|
return path.join(devtools_root_path(), 'scripts', 'hosted_mode', 'server.js')
|
|
|
|
|
|
def downloaded_chrome_binary_path():
|
|
return path.abspath(path.join(
|
|
*{
|
|
'Linux': (devtools_root_path(), 'third_party', 'chrome', 'chrome-linux', 'chrome'),
|
|
'Darwin': (devtools_root_path(), 'third_party', 'chrome', 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'),
|
|
'Windows': (devtools_root_path(), 'third_party', 'chrome', 'chrome-win', 'chrome.exe'),
|
|
}[platform.system()]))
|
|
|
|
|
|
def license_checker_path():
|
|
return path.join(node_modules_path(), 'license-checker', 'bin', 'license-checker')
|
|
|
|
|
|
def rollup_path():
|
|
return path.join(
|
|
node_modules_path(),
|
|
'rollup',
|
|
'dist',
|
|
'bin',
|
|
'rollup',
|
|
)
|
|
|
|
|
|
def package_lock_json_path():
|
|
return path.join(devtools_root_path(), 'package-lock.json')
|
|
|
|
|
|
def package_json_path():
|
|
return path.join(devtools_root_path(), 'package.json')
|
|
|
|
|
|
def browser_protocol_path():
|
|
return path.join(third_party_path(), 'blink', 'public', 'devtools_protocol', 'browser_protocol.pdl')
|