fix(cli): should ensure dir before output file

This commit is contained in:
陈嘉涵 2019-11-29 17:36:29 +08:00
parent 8bcfc13ce2
commit 9318e6b909

View File

@ -4,9 +4,9 @@
import dependencyTree from 'dependency-tree';
import { join } from 'path';
import { existsSync, writeFileSync } from 'fs';
import { getComponents } from '../common';
import { ES_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
import { existsSync, writeFileSync, ensureDirSync } from 'fs-extra';
import { ES_DIR, DIST_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
interface DependencyObj {
[k: string]: DependencyObj;
@ -115,6 +115,8 @@ export function genStyleDepsMap() {
);
});
ensureDirSync(DIST_DIR);
writeFileSync(
STYPE_DEPS_JSON_FILE,
JSON.stringify({ map, sequence }, null, 2)