Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintain: const over let, consistency #5494

Open
wants to merge 6 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -20,12 +20,12 @@ const touchOverriddenFiles = () => {
}

const chromiumSrcDir = path.join(config.srcDir, 'brave', 'chromium_src')
var sourceFiles = util.walkSync(chromiumSrcDir, applyFileFilter)
const sourceFiles = util.walkSync(chromiumSrcDir, applyFileFilter)

// Touch original files by updating mtime.
const chromiumSrcDirLen = chromiumSrcDir.length
sourceFiles.forEach(chromiumSrcFile => {
var overriddenFile = path.join(config.srcDir, chromiumSrcFile.slice(chromiumSrcDirLen))
const overriddenFile = path.join(config.srcDir, chromiumSrcFile.slice(chromiumSrcDirLen))
if (!fs.existsSync(overriddenFile)) {
// Try to check that original file is in gen dir.
overriddenFile = path.join(config.outputDir, 'gen', chromiumSrcFile.slice(chromiumSrcDirLen))

This comment has been minimized.

Copy link
@spirinvladimir

spirinvladimir Nov 21, 2019

assign to const overriddenFile!

@@ -48,18 +48,16 @@ const touchOverriddenVectorIconFiles = () => {
// Return true when original file of |file| should be touched.
const applyFileFilter = (file) => {
// Only includes icon files.
const ext = path.extname(file)
if (ext !== '.icon') { return false }
return true
return path.extname(file) === '.icon'
}

const braveVectorIconsDir = path.join(config.srcDir, 'brave', 'vector_icons')
var braveVectorIconFiles = util.walkSync(braveVectorIconsDir, applyFileFilter)
const braveVectorIconFiles = util.walkSync(braveVectorIconsDir, applyFileFilter)

// Touch original files by updating mtime.
const braveVectorIconsDirLen = braveVectorIconsDir.length
braveVectorIconFiles.forEach(braveVectorIconFile => {
var overriddenFile = path.join(config.srcDir, braveVectorIconFile.slice(braveVectorIconsDirLen))
const overriddenFile = path.join(config.srcDir, braveVectorIconFile.slice(braveVectorIconsDirLen))
if (fs.existsSync(overriddenFile)) {
// If overriddenFile is older than file in vector_icons, touch it to trigger rebuild.
if (fs.statSync(braveVectorIconFile).mtimeMs - fs.statSync(overriddenFile).mtimeMs > 0) {
@@ -17,7 +17,7 @@ const getNPMConfig = (path) => {
}

const parseExtraInputs = (inputs, accumulator, callback) => {
for (let input of inputs) {
for (const input of inputs) {
let separatorIndex = input.indexOf(':')
if (separatorIndex < 0) {
separatorIndex = input.length
@@ -87,12 +87,11 @@ const Config = function () {

Config.prototype.buildArgs = function () {
const version = this.braveVersion
let version_parts = version.split('+')[0]
version_parts = version_parts.split('.')
const version_parts = version.split('+')[0].split('.')

const chrome_version_parts = this.chromeVersion.split('.')

let args = {
const args = {
fieldtrial_testing_like_official_build: true,
safe_browsing_mode: 1,
brave_services_key: this.braveServicesKey,
@@ -303,7 +302,7 @@ Config.prototype.getProjectRef = function (projectName) {
return commit
}

let version = getNPMConfig(['projects', projectName, 'version'])
const version = getNPMConfig(['projects', projectName, 'version'])
let branch = getNPMConfig(['projects', projectName, 'branch'])
if (!branch && !version) {
return 'origin/master'
@@ -323,7 +322,7 @@ Config.prototype.getProjectRef = function (projectName) {
}

Config.prototype.buildProjects = function () {
for (let name in packages.config.projects) {
for (const name in packages.config.projects) {
this.projectNames.push(name)
}

@@ -491,11 +490,11 @@ Config.prototype.update = function (options) {

this.projectNames.forEach((projectName) => {
// don't update refs for projects that have them
let project = this.projects[projectName]
const project = this.projects[projectName]
if (!project.ref)
return

let ref = options[project.arg_name + '_ref']
const ref = options[project.arg_name + '_ref']
if (ref && ref !== 'default' && ref !== '') {
project.ref = ref
}
@@ -553,7 +552,7 @@ Object.defineProperty(Config.prototype, 'outputDir', {
get: function () {
if (this.__outputDir)
return this.__outputDir
let baseDir = path.join(this.srcDir, 'out')
const baseDir = path.join(this.srcDir, 'out')
let buildConfigDir = this.buildConfig
if (this.targetArch && this.targetArch != 'x64') {
buildConfigDir = buildConfigDir + '_' + this.targetArch
@@ -6,7 +6,7 @@
const path = require('path')
const fs = require('fs-extra')
const GitPatcher = require('./gitPatcher')
const { runAsync, runGitAsync } = require('./util')
const { runGitAsync } = require('./util')
const os = require('os')

const dirPrefixTmp = 'brave-browser-test-git-apply-'
@@ -101,7 +101,7 @@ const start = (passthroughArgs, buildConfig = config.defaultBuildConfig, options
}
}

let cmdOptions = {
const cmdOptions = {
stdio: 'inherit',
timeout: options.network_log ? 120000 : undefined,
continueOnFail: options.network_log ? true : false,
@@ -133,15 +133,14 @@ const start = (passthroughArgs, buildConfig = config.defaultBuildConfig, options

if (options.network_log) {
let exitCode = 0
let jsonOutput = {}
// Read the network log
let jsonContent = fs.readFileSync(networkLogFile, 'utf8').trim()
// On windows netlog ends abruptly causing JSON parsing errors
if (!jsonContent.endsWith('}]}')) {
const n = jsonContent.lastIndexOf('},')
jsonContent = jsonContent.substring(0, n) + '}]}'
}
jsonOutput = JSON.parse(jsonContent)
const jsonOutput = JSON.parse(jsonContent)

const URL_REQUEST_TYPE = jsonOutput.constants.logSourceType.URL_REQUEST
const URL_REQUEST_FAKE_RESPONSE_HEADERS_CREATED = jsonOutput.constants.logEventTypes.URL_REQUEST_FAKE_RESPONSE_HEADERS_CREATED
@@ -31,7 +31,7 @@ async function writePatchFiles (modifiedPaths, gitRepoPath, patchDirPath) {
}

let writeOpsDoneCount = 0
let writePatchOps = modifiedPaths.map(async (old, i) => {
const writePatchOps = modifiedPaths.map(async (old, i) => {
const singleDiffArgs = ['diff', '--src-prefix=a/', '--dst-prefix=b/', '--full-index', old]
const patchContents = await util.runAsync('git', singleDiffArgs, { cwd: gitRepoPath })
const patchFilename = patchFilenames[i]
@@ -36,7 +36,7 @@ const util = {
},

runAsync: (cmd, args = [], options = {}) => {
let { continueOnFail, verbose, ...cmdOptions } = options
const { continueOnFail, verbose, ...cmdOptions } = options
if (verbose) {
console.log(cmd, args.join(' '))
}
@@ -94,8 +94,8 @@ const util = {
return value;
}

let solutions = config.projectNames.filter((projectName) => config.projects[projectName].ref).map((projectName) => {
let project = config.projects[projectName]
const solutions = config.projectNames.filter((projectName) => config.projects[projectName].ref).map((projectName) => {
const project = config.projects[projectName]
return {
managed: "%False%",
name: project.gclientName,
@@ -104,7 +104,7 @@ const util = {
}
})

let cache_dir = process.env.GIT_CACHE_PATH ? ('\ncache_dir = "' + process.env.GIT_CACHE_PATH + '"\n') : '\n'
const cache_dir = process.env.GIT_CACHE_PATH ? ('\ncache_dir = "' + process.env.GIT_CACHE_PATH + '"\n') : '\n'

let out = 'solutions = ' + JSON.stringify(solutions, replacer, 2)
.replace(/"%None%"/g, "None").replace(/"%False%"/g, "False") + cache_dir
@@ -150,7 +150,7 @@ const util = {
const chromeAndroidJavaStringsTranslationsDir = path.join(config.srcDir, 'chrome', 'android', 'java', 'strings', 'translations')
const braveAndroidJavaStringsTranslationsDir = path.join(config.projects['brave-core'].dir, 'android', 'java', 'strings', 'translations')

let fileMap = new Set();
const fileMap = new Set();
// The following 3 entries we map to the same name, not the chromium equivalent name for copying back
autoGeneratedBraveToChromiumMapping[path.join(braveAppDir, 'brave_strings.grd')] = path.join(chromeAppDir, 'brave_strings.grd')
autoGeneratedBraveToChromiumMapping[path.join(braveAppDir, 'settings_brave_strings.grdp')] = path.join(chromeAppDir, 'settings_brave_strings.grdp')
@@ -232,8 +232,9 @@ const util = {

// Copy branding file
let branding_file_name = 'BRANDING'
if (config.channel)
if (config.channel) {
branding_file_name = branding_file_name + '.' + config.channel
}

const brandingSource = path.join(braveAppDir, 'theme', 'brave', branding_file_name)
const brandingDest = path.join(chromeAppDir, 'theme', 'brave', 'BRANDING')
@@ -378,14 +379,15 @@ const util = {
// Copy & sign only binaries for widevine sig file generation.
// With this, create_dist doesn't trigger rebuild because original binaries is not modified.
const dir = path.join(config.outputDir, 'signed_binaries')
if (!fs.existsSync(dir))
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}

fs.copySync(path.join(config.outputDir, 'brave.exe'), path.join(dir, 'brave.exe'));
fs.copySync(path.join(config.outputDir, 'chrome.dll'), path.join(dir, 'chrome.dll'));
fs.copySync(path.join(config.outputDir, 'chrome_child.dll'), path.join(dir, 'chrome_child.dll'));

const core_dir = config.projects['brave-core'].dir
const core_dir = config.projects['brave-core'].dir
util.run('python', [path.join(core_dir, 'script', 'sign_binaries.py'), '--build_dir=' + dir])
},

@@ -396,8 +398,9 @@ const util = {
const sig_generator = config.signature_generator
let src_dir = path.join(config.outputDir, 'signed_binaries')

if (config.skip_signing || process.env.CERT === undefined || process.env.SIGNTOOL_ARGS === undefined)
if (config.skip_signing || process.env.CERT === undefined || process.env.SIGNTOOL_ARGS === undefined) {
src_dir = config.outputDir
}

console.log('generate Widevine sig files...')

@@ -424,8 +427,12 @@ const util = {
buildTarget: (options = config.defaultOptions) => {
console.log('building ' + config.buildTarget + '...')

if (process.platform === 'win32') util.updateOmahaMidlFiles()
if (process.platform === 'linux') util.prepareWidevineCdmBuild()
if (process.platform === 'win32') {
util.updateOmahaMidlFiles()
}
if (process.platform === 'linux') {
util.prepareWidevineCdmBuild()
}

let num_compile_failure = 1
if (config.ignore_compile_failure)
@@ -434,7 +441,7 @@ const util = {
const args = util.buildArgsToString(config.buildArgs())
util.run('gn', ['gen', config.outputDir, '--args="' + args + '"'], options)

let ninjaOpts = [
const ninjaOpts = [
'-C', config.outputDir, config.buildTarget,
'-k', num_compile_failure,
...config.extraNinjaOpts
@@ -463,7 +470,7 @@ const util = {
if (!options.base) {
options.base = 'origin/master';
}
let cmd_options = config.defaultOptions
const cmd_options = config.defaultOptions
cmd_options.cwd = config.projects['brave-core'].dir
util.run('vpython', [path.join(config.rootDir, 'scripts', 'lint.py'),
'--project_root=' + config.srcDir,
@@ -507,15 +514,17 @@ const util = {
},

submoduleSync: (options = {}) => {
if (!options.cwd) options.cwd = config.rootDir // default cwd `./src` may not exist yet
if (!options.cwd) {
options.cwd = config.rootDir // default cwd `./src` may not exist yet
}
options = mergeWithDefault(options)
util.run('git', ['submodule', 'sync'], options)
util.run('git', ['submodule', 'update', '--init', '--recursive'], options)
util.fixDepotTools(options)
},

gclientSync: (reset = false, options = {}) => {
let args = ['sync', '--force', '--nohooks', '--with_branch_heads', '--with_tags']
const args = ['sync', '--force', '--nohooks', '--with_branch_heads', '--with_tags']
if (reset)
args.push('--upstream')
runGClient(args, options)
@@ -1,5 +1,4 @@
const config = require('../lib/config')
const util = require('../lib/util')

const versions = (buildConfig = config.defaultBuildConfig, options = {}) => {
config.buildConfig = buildConfig
@@ -19,7 +19,7 @@ function npmAudit (pathname) {
fs.existsSync(path.join(pathname, 'package-lock.json')) &&
fs.existsSync(path.join(pathname, 'node_modules'))) {
console.log('Auditing', pathname)
let cmdOptions = {
const cmdOptions = {
cwd: pathname,
shell: process.platform === 'win32' ? true : false
}
@@ -28,7 +28,7 @@ program
.option('--init', 'initialize all dependencies')
.option('--all', 'update all projects')
projectNames.forEach((name) => {
let project = config.projects[name]
const project = config.projects[name]
program.option('--' + project.arg_name + '_ref <ref>', name + ' ref to checkout')
})

@@ -61,7 +61,7 @@ async function RunCommand () {
const projectUpdateStatus = {}
await Promise.all(
projectNames.map(async (name) => {
let project = config.projects[name]
const project = config.projects[name]
if (alwaysReset || program.all || program[project.arg_name + '_ref']) {
projectUpdateStatus[name] = {
name,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.