From f1c700dd7d2c1a1488d245fae1e15d6b43dfcf8f Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Sun, 1 Jan 2023 02:29:25 +0900 Subject: [PATCH 1/2] test: use default import for fs-extra --- packages/create-vite/__tests__/cli.spec.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/create-vite/__tests__/cli.spec.ts b/packages/create-vite/__tests__/cli.spec.ts index 6f47f6e25aaa66..0db7338415e75a 100644 --- a/packages/create-vite/__tests__/cli.spec.ts +++ b/packages/create-vite/__tests__/cli.spec.ts @@ -1,7 +1,7 @@ import { join } from 'node:path' import type { ExecaSyncReturnValue, SyncOptions } from 'execa' import { execaCommandSync } from 'execa' -import { mkdirpSync, readdirSync, remove, writeFileSync } from 'fs-extra' +import fs from 'fs-extra' import { afterEach, beforeAll, expect, test } from 'vitest' const CLI_PATH = join(__dirname, '..') @@ -19,21 +19,22 @@ const run = ( // Helper to create a non-empty directory const createNonEmptyDir = () => { // Create the temporary directory - mkdirpSync(genPath) + fs.mkdirpSync(genPath) // Create a package.json file const pkgJson = join(genPath, 'package.json') - writeFileSync(pkgJson, '{ "foo": "bar" }') + fs.writeFileSync(pkgJson, '{ "foo": "bar" }') } // Vue 3 starter template -const templateFiles = readdirSync(join(CLI_PATH, 'template-vue')) +const templateFiles = fs + .readdirSync(join(CLI_PATH, 'template-vue')) // _gitignore is renamed to .gitignore .map((filePath) => (filePath === '_gitignore' ? '.gitignore' : filePath)) .sort() -beforeAll(() => remove(genPath)) -afterEach(() => remove(genPath)) +beforeAll(() => fs.remove(genPath)) +afterEach(() => fs.remove(genPath)) test('prompts for the project name if none supplied', () => { const { stdout } = run([]) @@ -41,7 +42,7 @@ test('prompts for the project name if none supplied', () => { }) test('prompts for the framework if none supplied when target dir is current directory', () => { - mkdirpSync(genPath) + fs.mkdirpSync(genPath) const { stdout } = run(['.'], { cwd: genPath }) expect(stdout).toContain('Select a framework:') }) @@ -79,7 +80,7 @@ test('successfully scaffolds a project based on vue starter template', () => { const { stdout } = run([projectName, '--template', 'vue'], { cwd: __dirname, }) - const generatedFiles = readdirSync(genPath).sort() + const generatedFiles = fs.readdirSync(genPath).sort() // Assertions expect(stdout).toContain(`Scaffolding project in ${genPath}`) @@ -90,7 +91,7 @@ test('works with the -t alias', () => { const { stdout } = run([projectName, '-t', 'vue'], { cwd: __dirname, }) - const generatedFiles = readdirSync(genPath).sort() + const generatedFiles = fs.readdirSync(genPath).sort() // Assertions expect(stdout).toContain(`Scaffolding project in ${genPath}`) From 6d1b721f8bbb3fd1ffa55e458b8b6364645cb6ff Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Sun, 1 Jan 2023 18:29:23 +0900 Subject: [PATCH 2/2] chore: rerun ci