Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: keithamus/sort-package-json
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.23.1
Choose a base ref
...
head repository: keithamus/sort-package-json
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.24.0
Choose a head ref
  • 3 commits
  • 4 files changed
  • 3 contributors

Commits on Nov 7, 2019

  1. Copy the full SHA
    491edb9 View commit details

Commits on Nov 25, 2019

  1. Copy the full SHA
    1c51598 View commit details
  2. Merge pull request #77 from eankeen/field/type

    adds 'type' field to list of properties to sort
    keithamus authored Nov 25, 2019
    Copy the full SHA
    4de7adb View commit details
Showing with 15 additions and 1 deletion.
  1. +1 −0 index.js
  2. +6 −0 package-lock.json
  3. +1 −0 package.json
  4. +7 −1 test.js
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ const sortOrder = [
'contributors',
'files',
'sideEffects',
'type',
'main',
'umd:main',
'unpkg',
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
},
"devDependencies": {
"husky": "^1.1.1",
"newline": "0.0.3",
"semantic-release": "^15.9.17",
"validate-commit-msg": "^2.14.0"
}
8 changes: 7 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
const assert = require('assert');
const sortPackageJson = require('./');
const fs = require('fs');
const newline = require('newline');
const sortPackageJson = require('./');

fs.readFile('./package.json', 'utf8', (error, contents) => {
if (error) {
console.error(error.stack || error);
process.exit(1);
}

// Enforce LF line-endings. Windows git users often set core.autocrlf
// to true, so the file may have CRLF line endings.
contents = newline.set(contents, "LF");

const parsed = JSON.parse(contents);
assert.deepEqual(
typeof sortPackageJson(parsed),