@jsenv/core 40.5.3 → 40.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -511,6 +511,35 @@ const SIGINT_CALLBACK = {
511
511
  },
512
512
  };
513
513
 
514
+ const isFileSystemPath = (value) => {
515
+ if (typeof value !== "string") {
516
+ throw new TypeError(
517
+ `isFileSystemPath first arg must be a string, got ${value}`,
518
+ );
519
+ }
520
+ if (value[0] === "/") {
521
+ return true;
522
+ }
523
+ return startsWithWindowsDriveLetter(value);
524
+ };
525
+
526
+ const startsWithWindowsDriveLetter = (string) => {
527
+ const firstChar = string[0];
528
+ if (!/[a-zA-Z]/.test(firstChar)) return false;
529
+
530
+ const secondChar = string[1];
531
+ if (secondChar !== ":") return false;
532
+
533
+ return true;
534
+ };
535
+
536
+ const fileSystemPathToUrl = (value) => {
537
+ if (!isFileSystemPath(value)) {
538
+ throw new Error(`value must be a filesystem path, got ${value}`);
539
+ }
540
+ return String(pathToFileURL(value));
541
+ };
542
+
514
543
  // https://github.com/Marak/colors.js/blob/master/lib/styles.js
515
544
  // https://stackoverflow.com/a/75985833/2634179
516
545
  const RESET = "\x1b[0m";
@@ -1462,35 +1491,6 @@ const ensurePathnameTrailingSlash = (url) => {
1462
1491
  });
1463
1492
  };
1464
1493
 
1465
- const isFileSystemPath = (value) => {
1466
- if (typeof value !== "string") {
1467
- throw new TypeError(
1468
- `isFileSystemPath first arg must be a string, got ${value}`,
1469
- );
1470
- }
1471
- if (value[0] === "/") {
1472
- return true;
1473
- }
1474
- return startsWithWindowsDriveLetter(value);
1475
- };
1476
-
1477
- const startsWithWindowsDriveLetter = (string) => {
1478
- const firstChar = string[0];
1479
- if (!/[a-zA-Z]/.test(firstChar)) return false;
1480
-
1481
- const secondChar = string[1];
1482
- if (secondChar !== ":") return false;
1483
-
1484
- return true;
1485
- };
1486
-
1487
- const fileSystemPathToUrl = (value) => {
1488
- if (!isFileSystemPath(value)) {
1489
- throw new Error(`value must be a filesystem path, got ${value}`);
1490
- }
1491
- return String(pathToFileURL(value));
1492
- };
1493
-
1494
1494
  const validateDirectoryUrl = (value) => {
1495
1495
  let urlString;
1496
1496