fix(cli): should check style exists when gen component style entry

This commit is contained in:
陈嘉涵 2019-12-21 08:55:22 +08:00
parent e8304a01bf
commit fad44923fb
2 changed files with 9 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import { join, relative } from 'path';
import { outputFileSync } from 'fs-extra'; import { outputFileSync } from 'fs-extra';
import { getComponents, replaceExt } from '../common'; import { getComponents, replaceExt } from '../common';
import { CSS_LANG, getCssBaseFile } from '../common/css'; import { CSS_LANG, getCssBaseFile } from '../common/css';
import { checkStyleExists } from './gen-style-deps-map';
import { import {
ES_DIR, ES_DIR,
SRC_DIR, SRC_DIR,
@ -17,7 +18,13 @@ function getDeps(component: string): string[] {
const styleDepsJson = require(STYPE_DEPS_JSON_FILE); const styleDepsJson = require(STYPE_DEPS_JSON_FILE);
if (styleDepsJson.map[component]) { if (styleDepsJson.map[component]) {
return [...styleDepsJson.map[component], component]; const deps = styleDepsJson.map[component].slice(0);
if (checkStyleExists(component)) {
deps.push(component);
}
return deps;
} }
return []; return [];

View File

@ -18,7 +18,7 @@ function getStylePath(component: string) {
return join(SRC_DIR, `${component}/index.${CSS_LANG}`); return join(SRC_DIR, `${component}/index.${CSS_LANG}`);
} }
function checkStyleExists(component: string) { export function checkStyleExists(component: string) {
return existsSync(getStylePath(component)); return existsSync(getStylePath(component));
} }