mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Updated linters, include typings in `package.json` and removed bun from the clean commands. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D54493859 fbshipit-source-id: eb28d208de722c90916b14f56d5a8e847bb3d859
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
* @oncall react_native
|
|
*/
|
|
|
|
import type {Task} from './types';
|
|
|
|
import execa from 'execa';
|
|
import os from 'os';
|
|
|
|
export function task(label: string, action: Task['action']): Task {
|
|
return {
|
|
action,
|
|
label,
|
|
};
|
|
}
|
|
|
|
export const isWindows = os.platform() === 'win32';
|
|
export const isMacOS = os.platform() === 'darwin';
|
|
|
|
export const toPascalCase = (label: string): string =>
|
|
label.length === 0 ? '' : label[0].toUpperCase() + label.slice(1);
|
|
|
|
type PathCheckResult = {
|
|
found: boolean,
|
|
dep: string,
|
|
description: string,
|
|
};
|
|
|
|
export function isOnPath(dep: string, description: string): PathCheckResult {
|
|
const result = execa.sync(isWindows ? 'where' : 'which', [dep]);
|
|
return {
|
|
dep,
|
|
description,
|
|
found: result.exitCode === 0,
|
|
};
|
|
}
|
|
|
|
export function assertDependencies(
|
|
...deps: $ReadOnlyArray<ReturnType<typeof isOnPath>>
|
|
) {
|
|
for (const {found, dep, description} of deps) {
|
|
if (!found) {
|
|
throw new Error(`"${dep}" not found, ${description}`);
|
|
}
|
|
}
|
|
}
|