JSPM

sort-scripts

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2908
  • Score
    100M100P100Q115113F
  • License MIT

Sort a map of scripts in a logical order

Package Exports

  • sort-scripts

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sort-scripts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sort-scripts

Sort scripts based on prefix and suffix

Usage

Given an map of script names to behavior (as is found in package.json files for Node projects), sort the scripts in a logical order, considering pre and post prefixes:

const sort = require('sort-scripts');
const scripts = {
  test: "jest",
  pretest: "check-engines",
  postmerge: "lint-staged",
  docs: "markdown-magic",
  postdocs: "echo \"'.md' files updated\""
};

sort(scripts);
// [
//   ["docs", "markdown-magic"], 
//   ["postdocs", "echo \"'.md' files updated\"],
//   ["postmerge", "lint-staged"],
//   ["pretest", "check-engines"],
//   ["test", "jest"]
// ]