|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
741 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | /*
|
|---|
| 2 | Copyright 2019 Google LLC
|
|---|
| 3 |
|
|---|
| 4 | Use of this source code is governed by an MIT-style
|
|---|
| 5 | license that can be found in the LICENSE file or at
|
|---|
| 6 | https://opensource.org/licenses/MIT.
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | import upath from 'upath';
|
|---|
| 10 |
|
|---|
| 11 | export function rebasePath({
|
|---|
| 12 | baseDirectory,
|
|---|
| 13 | file,
|
|---|
| 14 | }: {
|
|---|
| 15 | baseDirectory: string;
|
|---|
| 16 | file: string;
|
|---|
| 17 | }): string {
|
|---|
| 18 | // The initial path is relative to the current directory, so make it absolute.
|
|---|
| 19 | const absolutePath = upath.resolve(file);
|
|---|
| 20 |
|
|---|
| 21 | // Convert the absolute path so that it's relative to the baseDirectory.
|
|---|
| 22 | const relativePath = upath.relative(baseDirectory, absolutePath);
|
|---|
| 23 |
|
|---|
| 24 | // Remove any leading ./ as it won't work in a glob pattern.
|
|---|
| 25 | const normalizedPath = upath.normalize(relativePath);
|
|---|
| 26 |
|
|---|
| 27 | return normalizedPath;
|
|---|
| 28 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.