修复 windows 平台 npm run dist 任务异常的问题 (#301)

This commit is contained in:
秦天翔
2017-11-09 23:56:52 -06:00
committed by neverland
parent 874dd0cefa
commit fbcb691699
3 changed files with 12 additions and 5 deletions

View File

@@ -7,6 +7,8 @@ const path = require('path');
const components = require('./get-components')();
const dependencyTree = require('dependency-tree');
const SEP = path.sep;
components.forEach(componentName => {
const libDir = path.resolve(__dirname, '../../lib');
const content = analyzeDependencies(componentName, libDir).map(component => `require('../../vant-css/${component}.css');`);
@@ -19,7 +21,7 @@ function analyzeDependencies(componentName, libDir) {
search(dependencyTree({
directory: libDir,
filename: path.resolve(libDir, componentName, 'index.js'),
filter: path => path.indexOf('vant/lib/') !== -1
filter: path => path.indexOf(`vant${SEP}lib${SEP}`) !== -1
}), checkList);
return checkList.filter(component => checkComponentHasStyle(component));
}
@@ -27,7 +29,7 @@ function analyzeDependencies(componentName, libDir) {
function search(tree, checkList) {
tree && Object.keys(tree).forEach(key => {
search(tree[key], checkList);
const component = key.split('/vant/lib/')[1].replace('/index.js', '').replace('mixins/', '');
const component = key.split(`${SEP}vant${SEP}lib${SEP}`)[1].replace(`${SEP}index.js`, '').replace(`mixins${SEP}`, '');
if (checkList.indexOf(component) === -1) {
checkList.push(component);
}