Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niksy/sort-pkg
[DEPRECATED] Sort package.json file fields.
https://github.com/niksy/sort-pkg
Last synced: about 2 months ago
JSON representation
[DEPRECATED] Sort package.json file fields.
- Host: GitHub
- URL: https://github.com/niksy/sort-pkg
- Owner: niksy
- License: mit
- Created: 2016-08-14T07:52:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-27T09:41:35.000Z (about 4 years ago)
- Last Synced: 2024-10-18T04:04:45.917Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
![Deprecated project](https://img.shields.io/badge/status-deprecated-red.svg)
**This project is deprecated.**
Use [`sort-package-json`](https://github.com/keithamus/sort-package-json) instead.
---
# sort-pkg
[![Build Status][ci-img]][ci]
Sort package.json file fields.
In addition to sorting keys, it also sorts:
* `dependendencies`, `devDependencies`, `scripts`
* `keywords`, creating duplicate-free array and sorting alphabetically
* unknown package.json fields, placing them above `repository` field and sorting them alphabetically## Install
```sh
npm install sort-pkg --save
```## Usage
```js
var sortPkg = require('sort-pkg');var sortedPkg = sortPkg({
main: 'index.js',
misty: 'marley',
version: '1.0.0',
name: 'foo',
keywords: [
'joey',
'kobe',
'joey',
'gunner',
'coco',
'buddy',
'coco',
'buddy'
],
scripts: {
test: 'node test.js'
}
});console.log(sortedPkg);
/* {
name: 'foo',
version: '1.0.0',
main: 'index.js',
scripts: {
test: 'node test.js'
},
keywords: [
'buddy',
'coco',
'gunner',
'joey',
'kobe'
],
misty: 'marley'
} */
```## API
### sortPkg(pkgData)
Returns: `Object`
Sorts package.json file fields.
#### pkgData
Type: `Object`
package.json data to sort.
## License
MIT © [Ivan Nikolić](http://ivannikolic.com)
[ci]: https://travis-ci.org/niksy/sort-pkg
[ci-img]: https://travis-ci.org/niksy/sort-pkg.svg?branch=master