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

Run platform pre/post commands if default or combination is specified #45

Open
psylum opened this issue Aug 20, 2021 · 0 comments
Open

Comments

@psylum
Copy link

psylum commented Aug 20, 2021

I'm not sure if this would be reasonable as a feature, since it does add some implied logic to what will run, but given the following package.json as an example:

{
    "name": "run-script-os-test",
    "version": "1.0.0",
    "description": "shows desired use of pre/post handling.",
    "scripts": {
        "preascript:win32": "echo 1 - win32 prep",
        "preascript:nix": "echo 1 - linux prep",
        "ascript": "run-script-os",
        "ascript:default": "echo 2 - platform neutral command",
        "postascript:win32": "echo 3 - win32 cleanup",
        "postascript:nix": "echo 3 - linux cleanup"
    },
    "dependencies": {
        "run-script-os": "^1.1.6"
    }
}

If you do the following, here's the actual results:

$ npm install
# ..installation output elided..
$ npm run ascript

> [email protected] ascript /root
> run-script-os


> [email protected] ascript:default /root
> echo 2 - platform neutral command

2 - platform neutral command

I'd sort of expected the following:

$ npm run ascript

> [email protected] ascript /root
> run-script-os


> [email protected] preascript:nix /root
> echo 1 - linux prep

1 - linux prep

> [email protected] ascript:default /root
> echo 2 - platform neutral command

2 - platform neutral command

> [email protected] postascript:nix /root
> echo 3 - linux cleanup

3 - linux cleanup

Based on the readme, i had hoped that doing this might be a workaround, but it similarly does not trigger pre/post:

"ascript:nix:win32": "echo 2 - platform neutral command",

Would this type of behavior be useful, even if behind a flag passed to run-script-os that could be added to the main 'ascript' command? This would make the package.json far less verbose, but still allow for "handling" all the os specific things as necessary, since in many cases the actual command invocation doesn't change between platforms. I know that you can make this work with the current implementation by adding:

"ascript:win32": "echo 2 - platform neutral command",
"ascript:nix": "echo 2 - platform neutral command",

But as i've stated, it'd be nice to remove the additional verbosity if it could identify the platform or combo that will run and appropriately run the pre/post scripts associated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant