Skip to content

Commit

Permalink
fix(cli): jsx tsx is not processed as an index
Browse files Browse the repository at this point in the history
affects: @varlet/cli
  • Loading branch information
haoziqaq committed Jul 31, 2021
1 parent 103be9e commit 4079361
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/varlet-cli/src/shared/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const ROOT_DOCS_DIR = resolve(CWD, 'docs')
export const ESLINT_EXTENSIONS = ['.vue', '.ts', '.js', '.mjs']
export const WEBPACK_RESOLVE_EXTENSIONS = ['.js', '.jsx', '.vue', '.ts', '.tsx', '.css', '.less']
export const SCRIPTS_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js']
export const EXPORT_DIR_INDEXES = ['index.vue', 'index.tsx', 'index.ts', 'index.jsx', 'index.js']
export const STYLE_DIR_NAME = 'style'
export const EXAMPLE_DIR_NAME = 'example'
export const DOCS_DIR_NAME = 'docs'
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-cli/src/shared/fsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
readdir,
readFileSync,
} from 'fs-extra'
import { SCRIPTS_EXTENSIONS, SRC_DIR } from './constant'
import { EXPORT_DIR_INDEXES, SCRIPTS_EXTENSIONS, SRC_DIR } from './constant'

export async function getExportDirNames(): Promise<string[]> {
const srcDir: string[] = await readdir(SRC_DIR)
Expand All @@ -30,7 +30,7 @@ export const isScript = (file: string): boolean => pathExistsSync(file) && SCRIP
export const isLess = (file: string): boolean => pathExistsSync(file) && extname(file) === '.less'

export const isExportDir = (dir: string): boolean =>
pathExistsSync(resolve(dir, 'index.js')) || pathExistsSync(resolve(dir, 'index.ts'))
EXPORT_DIR_INDEXES.some((index) => pathExistsSync(resolve(dir, index)))

export const replaceExt = (file: string, ext: string): string => file.replace(extname(file), ext)

Expand Down

0 comments on commit 4079361

Please sign in to comment.