Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions tools/gulp/task_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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));
}
}

Expand Down
6 changes: 4 additions & 2 deletions tools/gulp/tasks/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
));
Expand Down