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

feat: better scripts order for follow npm run order #171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bluelovers
Copy link
Contributor

No description provided.

@bluelovers bluelovers changed the title feat: better scripts order for follow num run order feat: better scripts order for follow npm run order Apr 6, 2020
Copy link
Owner

@keithamus keithamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks cool. @fisker thoughts?

Copy link
Collaborator

@fisker fisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the package earlier, but didn't found many details, can you explain a little bit, how it different from the original one?

index.js Outdated Show resolved Hide resolved
@fisker
Copy link
Collaborator

fisker commented Apr 7, 2020

Another thing, this module deps on sort-object-keys2, can it merge with sort-object-keys? So we won't need add extra dependency.

@bluelovers
Copy link
Contributor Author

https://github.com/lerna/lerna/tree/master/commands/publish#lifecycle-scripts

https://docs.npmjs.com/misc/scripts#description


Object {
  "build": "12",
  "coverage": "17",
  "dev": "20",
  "install": "14",
  "link": "11",
  "lint": "16",
  "npm": "10",
  "pack": "5",
  "postpack": "4",
  "postpublish": "2",
  "prepack": "6",
  "prepare": "8",
  "prepublish": "9",
  "prepublishOnly": "7",
  "publish": "3",
  "restart": "19",
  "shrinkwrap": "1",
  "start": "21",
  "stop": "18",
  "test": "15",
  "uninstall": "13",
  "version": "0",
}

=>

Array [
  "start",
  "dev",
  "restart",
  "stop",
  "coverage",
  "lint",
  "test",
  "install",
  "uninstall",
  "build",
  "link",
  "npm",
  "prepublish",
  "prepare",
  "prepublishOnly",
  "prepack",
  "pack",
  "postpack",
  "publish",
  "postpublish",
  "shrinkwrap",
  "version",
]

@fisker
Copy link
Collaborator

fisker commented Apr 7, 2020

Those two links really didn't help me to understand, I took a quick look at source, if I understand correctly, you sort prettier and well-sorted default scripts first, right?

@bluelovers
Copy link
Contributor Author

bluelovers commented Apr 7, 2020

先以 defaultNpmScriptsOrder 作為優先排序
此順序依照 npm 執行 script 時的順序 來排序 或 將同類型 script 分組

接著 將出現在 otherNpmScriptsOrder 裡面的做特殊分組 因為 prettier 具有 pre 前置詞 會導致 omitKey 錯誤判斷

otherNpmScriptsOrder 至於這個的變數名稱 則無須理會 因為與實際上腳本邏輯不同

其他則依照原有設計 將 pre/post 做排序

分組排序過程中 無視 _ - : 等常見連接字 能藉此使非標準 script name 也能按照預期來排序

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

Successfully merging this pull request may close these issues.

3 participants