forked from brave/brave-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
38 lines (31 loc) · 1.4 KB
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2019 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.
const fs = require('fs')
const Log = require('../lib/logging')
const path = require('path')
const { spawnSync } = require('child_process')
const util = require('../lib/util')
Log.progress('Performing initial checkout of brave-core')
const braveCoreDir = path.resolve(__dirname, '..', 'src', 'brave')
const braveCoreRef = util.getProjectVersion('brave-core')
if (!fs.existsSync(path.join(braveCoreDir, '.git'))) {
Log.status(`Cloning brave-core [${braveCoreRef}] into ${braveCoreDir}...`)
fs.mkdirSync(braveCoreDir)
util.runGit(braveCoreDir, ['clone', util.getNPMConfig(['projects', 'brave-core', 'repository', 'url']), '.'])
util.runGit(braveCoreDir, ['checkout', braveCoreRef])
}
const braveCoreSha = util.runGit(braveCoreDir, ['rev-parse', 'HEAD'])
Log.progress(`brave-core repo at ${braveCoreDir} is at commit ID ${braveCoreSha}`)
let npmCommand = 'npm'
if (process.platform === 'win32') {
npmCommand += '.cmd'
}
util.run(npmCommand, ['install'], { cwd: braveCoreDir })
util.run(npmCommand, ['run', 'sync' ,'--', '--init'].concat(process.argv.slice(2)), {
cwd: braveCoreDir,
env: process.env,
stdio: 'inherit',
shell: true,
git_cwd: '.', })