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

Sort pre/post scripts with colon together #307

Open
ext opened this issue Jan 27, 2024 · 1 comment
Open

Sort pre/post scripts with colon together #307

ext opened this issue Jan 27, 2024 · 1 comment

Comments

@ext
Copy link

ext commented Jan 27, 2024

I often use pre and post scripts such as prebuild, build and postbuild. Sometimes I split them into multiple scripts such as prebuild:foo and prebuild:bar with prebuild running something like npm-run-all run-s.

The prebuild and postbuild is neatly sorted as expected:

{
  "scripts": {
    "prebuild": "..",
    "build": "..",
    "postbuild": ".."
  }
}

However when using : the sorting isn't as neat any longer, a longer example of this is:

{
  "scripts": {
    "prebuild": "run-s prebuild:*",
    "build": "run-s build:*",
    "postbuild": "run-s prebuild:*",
    "build:bar": "node bar.js",
    "build:baz": "node baz.js",
    "build:foo": "node foo.js",
    "d-unrelated": "..",
    "e-unrelated": "..",
    "f-unrelated": "..",
    "postbuild:1": "node prebuild.js 1",
    "postbuild:2": "node prebuild.js 2",
    "postbuild:3": "node prebuild.js 3",
    "prebuild:1": "node prebuild.js 1",
    "prebuild:2": "node prebuild.js 2",
    "prebuild:3": "node prebuild.js 3"
  }
}

The expected order would be:

{
  "scripts": {
    "prebuild": "run-s prebuild:*",
    "prebuild:1": "node prebuild.js 1",
    "prebuild:2": "node prebuild.js 2",
    "prebuild:3": "node prebuild.js 3",
    "build": "run-s build:*",
    "build:bar": "node bar.js",
    "build:baz": "node baz.js",
    "build:foo": "node foo.js",
    "postbuild": "run-s prebuild:*",
    "postbuild:1": "node prebuild.js 1",
    "postbuild:2": "node prebuild.js 2",
    "postbuild:3": "node prebuild.js 3",
    "d-unrelated": "..",
    "e-unrelated": "..",
    "f-unrelated": "..",
  }
}

If you think this is reasonable I could try to create a PR to implement this change.

@keithamus
Copy link
Owner

Sounds like a great idea. PRs welcome for this.

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

2 participants