From a9dcf5ced4e5ee538610aa135dbb1620c74200be Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 19 Jan 2022 10:42:19 -0500 Subject: [PATCH] Remove unecessary sorts, add undefined check to packageJson sort --- .../cli/src/lib/commands/workspace-lint.ts | 34 +------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/packages/cli/src/lib/commands/workspace-lint.ts b/packages/cli/src/lib/commands/workspace-lint.ts index 5e29c247..2148fc7f 100644 --- a/packages/cli/src/lib/commands/workspace-lint.ts +++ b/packages/cli/src/lib/commands/workspace-lint.ts @@ -17,46 +17,14 @@ function sortItems(items: Record = {}) { .reduce((acc, curr) => ({ ...acc, [curr]: items[curr] }), {}) } -export function sortTsConfigPaths(file) { - return { - ...file, - compilerOptions: { - ...file?.compilerOptions, - paths: sortItems(file?.compilerOptions?.paths), - }, - } -} - -export function sortWorkspaceProjects(file) { - return { - ...file, - projects: sortItems(file?.projects), - } -} - export function sortPackageJson(file) { return { ...file, - scripts: sortItems(file?.scripts), + ...(file?.scripts ? { scripts: sortItems(file?.scripts) } : {}), } } export async function workspaceLint({ dryRun, skipPackageJson }: { dryRun: boolean; skipPackageJson: boolean }) { - for (const file of projectFiles) { - const contents = await getFileContents(file) - if (contents && !dryRun) { - await writeJson(file, sortWorkspaceProjects(contents), { spaces: 2 }) - execSync('prettier --write ' + file) - } - } - - for (const file of tsconfigFiles) { - const contents = await getFileContents(file) - if (contents && !dryRun) { - await writeJson(file, sortTsConfigPaths(contents), { spaces: 2 }) - execSync('prettier --write ' + file) - } - } if (!skipPackageJson) { const file = 'package.json' const contents = await getFileContents(file)