Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Create *.ps1 file instead of embedded script #8

Closed

Description

@iRon7

Another thought re installation: you could simply turn your *.ps1 file into a script that can be invoked directly rather than embedding a function definition in it. Now that Install-Script offers to put the folder for installed scripts in $env:PATH, that is sufficient.

Activity

  1. added
    enhancement
    on Oct 18, 2020
  2. iRon7 commented on Oct 22, 2020

    @iRon7
    OwnerAuthor

    @mklement0, I am investigating this and I am afraid that I will lose the possibility to set an alias for the script (Set-Alias ctex ConvertTo-Expression). The only option is to move to a module but I want to keep the whole setup simple.
    Actually, I think that it should be possible set an alias through the Meta data set by new-scriptfileinfo/new-scriptfileinfo which should than be implemented by the Install-Script cmdlet. Agree?

  3. self-assigned this
    on Oct 22, 2020
  4. mklement0 commented on Oct 22, 2020

    @mklement0

    Yes, aliases are a problem.

    It would indeed be nice if you could specify them via New-ScriptFileInfo and if PowerShell would automatically define them.

    I suppose the alias information could be included in the <scrpt-dir>/InstalledScriptInfo/*.xml files created by Install-Script and read by the engine on startup - without too much of a performance impact (analogous to how module manifests are scanned).

    On the other hand you could make the argument that predefining aliases for the user should be limited to modules.

    I encourage you to open a feature request and see what others think.

  5. mklement0 commented on Oct 25, 2020

    @mklement0

    Btw, another problem with using *.ps1 files directly as commands is that on case-sensitive file-systems - notably on Linux by default - you'll only be able to invoke the script if you match the file name's case exactly - which is both inconvenient and unexpected.

  6. iRon7 commented on Apr 10, 2024

    @iRon7
    OwnerAuthor

    Covered by the ObjectGraphTools module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions