From 96b2e2fc476036ac5f9266eed061c91d2adbf2e9 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Mon, 18 Feb 2019 07:59:03 +0100 Subject: [PATCH] chore: avoid mutation on sort --- src/lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/utils.js b/src/lib/utils.js index d92c4b532..2ace784d2 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -413,7 +413,7 @@ export function fileExists(path: string): boolean { } export function sortByName(packages: Array, orderAscending: boolean | void = true): string[] { - return packages.sort(function(a, b) { + return packages.slice().sort(function(a, b) { const comparatorNames = a.name.toLowerCase() < b.name.toLowerCase(); return orderAscending ? (comparatorNames ? -1 : 1) : comparatorNames ? 1 : -1;