kibana/src/dev/build/tasks/patch_native_modules_task.js
Yulong bb92b8b8b5
[Code] replace nodegit with native git (#45491) (#47920)
* [Code]  use native git to iterate git files
* [Code] use native git to clone/update repository
* [Code] git history using native git
* [Code] use native git to read file tree and file content
* [Code] fix the 'bad file' warning from status api
* [Code] use native git to handle worktree
* [Code] use native git to resolve references
* [Code] use native git to handle blame / diff
* [Code] patch git binaries in kibana build script
* [Code] migrate unit tests to use native git
2019-10-11 12:50:06 +08:00

47 lines
1.8 KiB
JavaScript

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import install from '@elastic/simple-git/scripts/install';
import { deleteAll } from '../lib';
import path from 'path';
async function patchGit(config, log, build, platform) {
const downloadPath = build.resolvePathForPlatform(platform, '.git_binaries', 'git.tar.gz');
const destination = build.resolvePathForPlatform(
platform,
'node_modules/@elastic/simple-git/native/git'
);
log.debug('Replacing git binaries from ' + downloadPath + ' to ' + destination);
const p = platform.isWindows() ? 'win32' : platform.getName();
await deleteAll([destination]);
await install(p, downloadPath, destination);
await deleteAll([path.dirname(downloadPath)], log);
}
export const PatchNativeModulesTask = {
description: 'Patching platform-specific native modules directories',
async run(config, log, build) {
await Promise.all(
config.getTargetPlatforms().map(async platform => {
if (!build.isOss()) {
await patchGit(config, log, build, platform);
}
})
);
},
};