From 542d8ba1acfc14d184a7b8affbfe791cf2b6a114 Mon Sep 17 00:00:00 2001 From: Alexander Kachkaev Date: Mon, 29 Jan 2024 12:46:13 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20don=E2=80=99t=20sort=20scripts=20when?= =?UTF-8?q?=20`npm-run-all2`=20is=20installed=20(#309)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 5 ++++- tests/scripts.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 26dfe9d4..cb02bc63 100755 --- a/index.js +++ b/index.js @@ -163,7 +163,10 @@ const sortScripts = onObject((scripts, packageJson) => { return name }) - if (!hasDevDependency('npm-run-all', packageJson)) { + if ( + !hasDevDependency('npm-run-all', packageJson) && + !hasDevDependency('npm-run-all2', packageJson) + ) { keys.sort() } diff --git a/tests/scripts.js b/tests/scripts.js index 0e5aa1da..8a417c60 100644 --- a/tests/scripts.js +++ b/tests/scripts.js @@ -68,3 +68,20 @@ for (const field of ['scripts', 'betterScripts']) { }, }) } + +for (const field of ['scripts', 'betterScripts']) { + test(`${field} when npm-run-all2 is not a dev dependency`, macro.sortObject, { + value: { [field]: fixture }, + expect: { [field]: expectAllSorted }, + }) + test(`${field} when npm-run-all2 is a dev dependency`, macro.sortObject, { + value: { + [field]: fixture, + devDependencies: { 'npm-run-all2': '^1.0.0' }, + }, + expect: { + [field]: expectPreAndPostSorted, + devDependencies: { 'npm-run-all2': '^1.0.0' }, + }, + }) +}