-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sorting scripts only by pre/post criteria (#206)
* feat: add option for custom sorting fields The fields option will override the values in the builtin fields array, allowing users to signify that a given key should not be sorted, or sorted in a particular way. * test: add tests for typings * feat: don't sort scripts if npm-run-all is a devDependency * fix: don't reorder scripts if we detect npm-run-all commands * fix: disable sorting scripts * fix: do not sort scripts except pre/post
- Loading branch information
1 parent
20830e1
commit 9b76ec1
Showing
8 changed files
with
1,191 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,49 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
declare namespace sortPackageJsonExports { | ||
declare namespace sortPackageJson { | ||
interface SortPackageJsonFn { | ||
/** | ||
* Sort packageJson object. | ||
* | ||
* @param packageJson - A packageJson | ||
* @param options | ||
* @returns Sorted packageJson object | ||
*/ | ||
<T extends Record<any, any>>(packageJson: T, options?: Options): T, | ||
* Sort packageJson object. | ||
* | ||
* @param packageJson - A packageJson | ||
* @param options - An options object | ||
* @returns Sorted packageJson object | ||
*/ | ||
<T extends Record<any, any>>(packageJson: T, options?: Options): T | ||
|
||
/** | ||
* Sort packageJson string. | ||
* | ||
* @param packageJson - A packageJson string. | ||
* @param options | ||
* @returns Sorted packageJson string. | ||
*/ | ||
(packageJson: string, options?: Options): string, | ||
* Sort packageJson string. | ||
* | ||
* @param packageJson - A packageJson string. | ||
* @param options - An options object | ||
* @returns Sorted packageJson string. | ||
*/ | ||
(packageJson: string, options?: Options): string | ||
} | ||
|
||
type ComparatorFunction = (left: string, right: string) => number; | ||
type ComparatorFunction = (left: string, right: string) => number | ||
|
||
function sortObjectBy<T extends Record<any, any>>( | ||
comparator?: string[], | ||
deep?: boolean, | ||
): (x: T) => T | ||
|
||
interface Field { | ||
readonly key: string | ||
over?<T extends Record<any, any>>(x: T): T | ||
} | ||
|
||
interface Options { | ||
readonly sortOrder?: readonly string[] | ComparatorFunction; | ||
readonly sortOrder?: readonly string[] | ComparatorFunction | ||
} | ||
} | ||
|
||
interface sortPackageJsonExports extends sortPackageJsonExports.SortPackageJsonFn { | ||
readonly default: sortPackageJsonExports.SortPackageJsonFn; | ||
readonly sortPackageJson: sortPackageJsonExports.SortPackageJsonFn; | ||
interface sortPackageJsonExports extends sortPackageJson.SortPackageJsonFn { | ||
readonly default: sortPackageJson.SortPackageJsonFn | ||
readonly sortPackageJson: sortPackageJson.SortPackageJsonFn | ||
readonly sortOrder: string[] | ||
} | ||
|
||
declare const sortPackageJsonExports: sortPackageJsonExports; | ||
declare const sortPackageJsonExports: sortPackageJsonExports | ||
|
||
export = sortPackageJsonExports; | ||
export = sortPackageJsonExports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.