From ad98b5b54728a5f066901e496cd30a459f642d37 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 18 Oct 2022 14:15:30 +0200 Subject: [PATCH] no promise chaining --- code/lib/builder-manager/src/utils/files.ts | 3 ++- code/lib/core-server/src/core-presets.test.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/code/lib/builder-manager/src/utils/files.ts b/code/lib/builder-manager/src/utils/files.ts index cf279e16a30..8c1672608b1 100644 --- a/code/lib/builder-manager/src/utils/files.ts +++ b/code/lib/builder-manager/src/utils/files.ts @@ -12,7 +12,8 @@ export async function readOrderedFiles( // convert deeply nested paths to a single level, also remove special characters const { location, url } = sanitizePath(file, addonsDir); - await fs.ensureFile(location).then(() => fs.writeFile(location, file.contents)); + await fs.ensureFile(location); + await fs.writeFile(location, file.contents); return url; }) || [] ); diff --git a/code/lib/core-server/src/core-presets.test.ts b/code/lib/core-server/src/core-presets.test.ts index ea1905be693..a28c334e481 100644 --- a/code/lib/core-server/src/core-presets.test.ts +++ b/code/lib/core-server/src/core-presets.test.ts @@ -53,15 +53,15 @@ jest.mock('@storybook/telemetry', () => ({ })); jest.mock('fs-extra', () => ({ copy: jest.fn(() => undefined), - ensureFile: jest.fn(() => undefined), - writeFile: jest.fn(() => undefined), - readFile: jest.fn((f) => ''), emptyDir: jest.fn(() => undefined), - ensureDir: jest.fn(() => undefined), - writeJSON: jest.fn(() => undefined), - remove: jest.fn(() => undefined), - readJSON: jest.fn(() => ({})), + ensureDir: jest.fn(() => true), + ensureFile: jest.fn(() => undefined), pathExists: jest.fn(() => true), + readFile: jest.fn((f) => ''), + readJSON: jest.fn(() => ({})), + remove: jest.fn(() => undefined), + writeFile: jest.fn(() => undefined), + writeJSON: jest.fn(() => undefined), })); jest.mock('./utils/StoryIndexGenerator', () => {