Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ls): Enhance compatibility and optimize path handling for Windows system #9

Merged
merged 11 commits into from
May 21, 2024

Commits on May 14, 2024

  1. fix: Fix path extraction from URL in Windows

    In this change, refactored the local `fileUrlToPath` and `ls` function on extracting the string path from given URL object. Utilizing the `url.fileURLToPath` to ensure it extracted correctly in Windows instead of extract directly from `pathname` property which add trailing slash ('/') before the drive letter. For instance:
    
    Output using `pathname` property:
      "/D:/a/b/c"
    
    Output using `url.fileURLToPath`:
      "D:\\a\\b\\c"
    
      Combined with path separator replacement:
        "D:/a/b/c"
    mitsuki31 committed May 14, 2024
    Configuration menu
    Copy the full SHA
    f130d45 View commit details
    Browse the repository at this point in the history

Commits on May 18, 2024

  1. feat: Add regex and function for path detection

    Added two constant variables containing regular expression pattern to parse file URL and Windows path, and added a new function called `isWin32Path` to detects whether the given path is a Windows path.
    mitsuki31 committed May 18, 2024
    Configuration menu
    Copy the full SHA
    a80db2d View commit details
    Browse the repository at this point in the history

Commits on May 19, 2024

  1. feat: Add new function to resolve file URL path

    Added a new function to resolve file URL path to a file path. The given path should be a valid file URL following the WHATWG URL Standard.
    
    If the provided URL is 'file://' or 'file:///', it is replaced with the root directory path (in the current drive for Windows systems). Otherwise, the URL is parsed using the `fileURLToPath` function.
    mitsuki31 committed May 19, 2024
    Configuration menu
    Copy the full SHA
    5e8d8b4 View commit details
    Browse the repository at this point in the history
  2. fix(ls): Enhance Windows path resolution

    Fixed and enhanced the Windows path resolution on `ls` function. Where in Windows systems the function cannot resolve the absolute path, because the drive letter path are treated as file URL path and causing an error.
    mitsuki31 committed May 19, 2024
    Configuration menu
    Copy the full SHA
    879d1f6 View commit details
    Browse the repository at this point in the history

Commits on May 20, 2024

  1. refactor: Deprecate a function and re-sort imports

    Deprecated the `fileUrlToPath` function and re-sorted the import statements.
    mitsuki31 committed May 20, 2024
    Configuration menu
    Copy the full SHA
    cd61ed8 View commit details
    Browse the repository at this point in the history

Commits on May 21, 2024

  1. fix: Fix error while stating read-protected entry

    Fixed the error while attempting to stat an entry that are read-protected due to a permission error (EPERM) or access error (EACCES).
    
    If throws an error during stating, then it attempts to open the entry using `fs.opendir` , if throw an error with code ENOTDIR we can coclude that the entry is a regular file, otherwise, it is a directory. We also not forget to close the `Dir` instance to avoid unexpected behavior. In addition, we also sort the result entries exact before it being returned.
    mitsuki31 committed May 21, 2024
    Configuration menu
    Copy the full SHA
    55b45c6 View commit details
    Browse the repository at this point in the history
  2. test(lib): Refactor the TestError class

    - Added a parameter to `TestError` constructor, it accepts an object.
    - In the `it` function, changed the error message and passed the cause error to the `cause` field in `opts` parameter.
    mitsuki31 committed May 21, 2024
    Configuration menu
    Copy the full SHA
    b0e025c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c4349f0 View commit details
    Browse the repository at this point in the history
  4. chore(scripts): Add several new npm scripts

    - `prepublishOnly`: Builds the project with '--overwrite' argument.
    - `prepack`: Tests the project before packing the project (`npm pack`).
    mitsuki31 committed May 21, 2024
    Configuration menu
    Copy the full SHA
    62bce18 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    10e4af3 View commit details
    Browse the repository at this point in the history
  6. ci: Add Windows to runs-on field

    Now it runs on Windows to check the compatibility both on Ubuntu (Linux) and Windows systems.
    mitsuki31 committed May 21, 2024
    Configuration menu
    Copy the full SHA
    f418f50 View commit details
    Browse the repository at this point in the history