diff --git a/tools/gulp/task_helpers.ts b/tools/gulp/task_helpers.ts index fa21f9915e47..f8941e659f55 100644 --- a/tools/gulp/task_helpers.ts +++ b/tools/gulp/task_helpers.ts @@ -19,7 +19,16 @@ const resolveBin = require('resolve-bin'); /** If the string passed in is a glob, returns it, otherwise append '**\/*' to it. */ function _globify(maybeGlob: string, suffix = '**/*') { - return maybeGlob.indexOf('*') != -1 ? maybeGlob : path.join(maybeGlob, suffix); + if (maybeGlob.indexOf('*') != -1) { + return maybeGlob; + } + try { + const stat = fs.statSync(maybeGlob); + if (stat.isFile()) { + return maybeGlob; + } + } catch (e) {} + return path.join(maybeGlob, suffix); } @@ -133,9 +142,11 @@ export function execNodeTask(packageName: string, executable: string | string[], /** Copy files from a glob to a destination. */ -export function copyTask(srcGlobOrDir: string, outRoot: string) { - return () => { - return gulp.src(_globify(srcGlobOrDir)).pipe(gulp.dest(outRoot)); +export function copyTask(srcGlobOrDir: string | string[], outRoot: string) { + if (typeof srcGlobOrDir === 'string') { + return () => gulp.src(_globify(srcGlobOrDir)).pipe(gulp.dest(outRoot)); + } else { + return () => gulp.src(srcGlobOrDir.map(name => _globify(name))).pipe(gulp.dest(outRoot)); } } diff --git a/tools/gulp/tasks/components.ts b/tools/gulp/tasks/components.ts index 90e4f0283d39..30d39c6d7246 100644 --- a/tools/gulp/tasks/components.ts +++ b/tools/gulp/tasks/components.ts @@ -28,8 +28,10 @@ task(':watch:components:spec', () => { task(':build:components:ts', tsBuildTask(componentsDir)); task(':build:components:spec', tsBuildTask(path.join(componentsDir, 'tsconfig-spec.json'))); -task(':build:components:assets', - copyTask(path.join(componentsDir, '*/**/*.!(ts|spec.ts)'), DIST_COMPONENTS_ROOT)); +task(':build:components:assets', copyTask([ + path.join(componentsDir, '**/*.!(ts|spec.ts)'), + path.join(PROJECT_ROOT, 'README.md'), +], DIST_COMPONENTS_ROOT)); task(':build:components:scss', sassBuildTask( DIST_COMPONENTS_ROOT, componentsDir, [path.join(componentsDir, 'core/style')] ));