mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
## Summary Adds the `node scripts/relocate` functionality, that helps moving modules to their intended locations, according to the _Sustainable Kibana Architecture_. Please refer to the README.md for further details and usage. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the "Elastic License
|
|
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
* Public License v 1"; you may not use this file except in compliance with, at
|
|
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
*/
|
|
|
|
import util from 'util';
|
|
import { exec } from 'child_process';
|
|
|
|
export const execAsync = util.promisify(exec);
|
|
|
|
export const safeExec = async (command: string, critical = true, log = true) => {
|
|
try {
|
|
if (log) {
|
|
// eslint-disable-next-line no-console
|
|
console.log(' >', command);
|
|
}
|
|
const result = await execAsync(command, { maxBuffer: 1024 * 1024 * 128 });
|
|
return result;
|
|
} catch (err) {
|
|
const message = `Error executing ${command}: ${err}`;
|
|
|
|
if (critical) {
|
|
throw err;
|
|
}
|
|
return { stdout: '', stderr: message };
|
|
}
|
|
};
|
|
|
|
export const quietExec = async (command: string) => {
|
|
return await safeExec(command, false, false);
|
|
};
|