HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //usr/share/opensearch-dashboards/node_modules/@osd/cross-platform/README.md
# `@osd/cross-platform` — OpenSearch Dashboards cross-platform helpers

This package contains the helpers to work around the differences across platforms, such as the difference in the path segment separator and the possibility of referencing a path using the short 8.3 name (SFN), a long name, and a long UNC on Windows. 

Some helpers are functions that `standardize` the reference to a path or help `getRepoRoot`, and some are constants referencing the `PROCESS_WORKING_DIR` or `REPO_ROOT`.

### Example

When the relative reference of `path` to the working directory is needed, using the code below would produce different results on Linux that it would on Windows and if the process was started in a Windows shell that used short paths, the results differ from a Windows shell that used long paths.
```js
import { relative } from 'path';

const relativePath = relative(process.cwd(), path);

// Output on Linux: relative-path/to/a/file
//         Windows: relative-path\to\a\file
//     Windows SFN: RELATI~1\to\a\file
```

To avoid those differences, helper functions and constants can be used:
```js
import { relative } from 'path';
import { standardize, PROCESS_WORKING_DIR } from '@osd/cross-platform';

const relativePath = standardize(relative(PROCESS_WORKING_DIR, path));

// Output: relative-path/to/a/file
```