From 869178f78496df2c9556b5b6124c1b07a7b814ce Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 10 Jan 2020 19:13:05 +0800 Subject: [PATCH] fix: missing type check on `sortScripts` (#139) * fix: missing type check on `sortScripts` * perf: skip type check inside `sortScripts` --- index.js | 6 +++--- tests/_helpers.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 933ac635..de79f797 100644 --- a/index.js +++ b/index.js @@ -113,7 +113,7 @@ const defaultNpmScripts = new Set([ 'version', ]) -const sortScripts = scripts => { +const sortScripts = onObject(scripts => { const names = Object.keys(scripts) const prefixable = new Set() @@ -136,8 +136,8 @@ const sortScripts = scripts => { [], ) - return sortObjectBy(order)(scripts) -} + return sortObjectKeys(scripts, order) +}) // fields marked `vscode` are for `Visual Studio Code extension manifest` only // https://code.visualstudio.com/api/references/extension-manifest diff --git a/tests/_helpers.js b/tests/_helpers.js index adfd876b..827689b8 100644 --- a/tests/_helpers.js +++ b/tests/_helpers.js @@ -85,8 +85,8 @@ function asItIs(t, { path, options }, excludeTypes = []) { ) } - for (const value of ['string', false, 2020]) { - const type = typeof value + for (const value of ['string', false, 2020, undefined, null]) { + const type = value === null ? 'null' : typeof value if (!excludeTypes.includes(type)) { t.is( sortPackageJsonAsObject({ path, value, options }),