UNPKG

1.06 kBJavaScriptView Raw
1/**
2 * Copyright IBM Corp. 2019, 2019
3 *
4 * This source code is licensed under the Apache-2.0 license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8'use strict';
9
10const execa = require('execa');
11
12/**
13 * For certain release types, we want to be certain that our base branch is
14 * up-to-date with the upstream remote. This helper will first check that the
15 * upstream remote exists, and create it if it does not, and then will pull the
16 * latest changes into the local project.
17 *
18 * @returns {void}
19 */
20async function fetchLatestFromUpstream() {
21 try {
22 // This command will fail is no upstream is present, with `catch` we can
23 // create the appropriate remote before running the next commands
24 await execa('git', ['remote', 'get-url', 'upstream']);
25 } catch {
26 await execa('git', [
27 'remote',
28 'add',
29 'upstream',
30 'git@github.com:carbon-design-system/carbon.git',
31 ]);
32 }
33 await execa('git', ['fetch', 'upstream', 'master', '--tags']);
34}
35
36module.exports = {
37 fetchLatestFromUpstream,
38};