Kikobeats / finepack

Organizes and maintains readable your JSON files.
MIT License
19 stars 7 forks source link

properties aren't being sorted #11

Closed pdehaan closed 8 years ago

pdehaan commented 9 years ago

Not sure if this is a regression, or expected or...

Steps to reproduce

  1. Go to a clean folder
  2. npm init
  3. Fill in all the fields.
  4. finepack package.json

    Actual results:

    Before finepack:

{
  "name": "finepack-test2",
  "version": "1.0.0",
  "description": "this is a desc",
  "main": "index.js",
  "dependencies": {},
  "devDependencies": {},
  "scripts": {
    "test": "eslint ."
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/git/repo"
  },
  "keywords": [
    "keywords"
  ],
  "author": "Peter deHaan <peter@deseloper.com> (http://nodeexamples.com/)",
  "license": "WTFPL",
  "bugs": {
    "url": "https://github.com/git/repo/issues"
  },
  "homepage": "https://github.com/git/repo"
}

After finepack:

{
  "name": "finepack-test2",
  "description": "this is a desc",
  "homepage": "https://github.com/git/repo",
  "version": "1.0.0",
  "main": "index.js",
  "author": "Peter deHaan <peter@deseloper.com> (http://nodeexamples.com/)",
  "repository": {
    "type": "git",
    "url": "https://github.com/git/repo"
  },
  "bugs": {
    "url": "https://github.com/git/repo/issues"
  },
  "keywords": [
    "keywords"
  ],
  "dependencies": {},
  "devDependencies": {},
  "scripts": {
    "test": "eslint ."
  },
  "license": "WTFPL"
}

Expected results:

Sorted properties (per the documentation: "Sorts the rest of the keys alphabetically and recursively."):

{
  "name": "finepack-test2",
  "description": "this is a desc",
  "version": "1.0.0",
  "author": "Peter deHaan <peter@deseloper.com> (http://nodeexamples.com/)",
  "bugs": {
    "url": "https://github.com/git/repo/issues"
  },
  "dependencies": {},
  "devDependencies": {},
  "homepage": "https://github.com/git/repo",
  "keywords": [
    "keywords"
  ],
  "license": "WTFPL",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/git/repo"
  },
  "scripts": {
    "test": "eslint ."
  }
}
Kikobeats commented 9 years ago

yes, but not all keys are sorted alphabetically. check important keys that are sorted in the top on the file, and, the rest, alphabetically

pdehaan commented 9 years ago

Yes, but I don't think the rest are being sorted alphabetically: Keywords Dependencies DevDependencies Scripts Licence

Kikobeats commented 9 years ago

yea, is the behavior that I want to follow a custom schema :-)