From 052d0743583a929cfbe0c5812f0548d2a3c924a4 Mon Sep 17 00:00:00 2001 From: jlukic Date: Fri, 20 Feb 2015 15:26:47 -0500 Subject: [PATCH] #1607 Fix components without assets not creating manifest lists correctly --- tasks/admin/components/create.js | 62 ++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/tasks/admin/components/create.js b/tasks/admin/components/create.js index cc79be40b..478142f47 100644 --- a/tasks/admin/components/create.js +++ b/tasks/admin/components/create.js @@ -34,6 +34,7 @@ var rename = require('gulp-rename'), replace = require('gulp-replace'), tap = require('gulp-tap'), + util = require('gulp-util'), // config config = require('../../config/user'), @@ -72,6 +73,12 @@ module.exports = function(callback) { repoName = release.componentRepoRoot + capitalizedComponent, gitURL = 'https://github.com/' + release.org + '/' + repoName + '.git', repoURL = 'https://github.com/' + release.org + '/' + repoName + '/', + concatSettings = { + newline : '', + root : outputDirectory, + prepend : " '", + append : "'," + }, regExp = { match : { // templated values @@ -119,10 +126,13 @@ module.exports = function(callback) { notes : component + ' create release notes', composer : component + ' create composer.json', package : component + ' create package.json', - meteor : component + ' create package.js', + meteor : component + ' create meteor package.js', }, // paths to includable assets - assetPath = '/assets/**/' + component + '?(s).*' + manifest = { + assets : outputDirectory + '/assets/**/' + component + '?(s).*', + component : outputDirectory + '/' + component + '+(.js|.css)' + } ; // copy dist files into output folder adjusting asset paths @@ -265,32 +275,32 @@ module.exports = function(callback) { // Creates meteor package.js gulp.task(task.meteor, function() { var - fileNames = '' + filenames = '' ; - if(isJavascript) { - fileNames += ' \'' + component + '.js\',\n'; - } - if(isCSS) { - fileNames += ' \'' + component + '.css\',\n'; - } - return gulp.src(outputDirectory + assetPath, { base: outputDirectory}) - .pipe(concatFileNames('/dev/null', { - newline : '', - root : outputDirectory, - prepend : ' \'', - append : '\',' + return gulp.src(manifest.component) + .pipe(concatFileNames('empty.txt', concatSettings)) + .pipe(tap(function(file) { + filenames += file.contents; })) - .pipe(tap(function(file) { fileNames += file.contents; })) - .on('end', function(){ - gulp.src(release.templates.meteor.component) - .pipe(plumber()) - .pipe(flatten()) - .pipe(replace(regExp.match.name, regExp.replace.name)) - .pipe(replace(regExp.match.titleName, regExp.replace.titleName)) - .pipe(replace(regExp.match.version, version)) - .pipe(replace(regExp.match.files, fileNames)) - .pipe(rename(release.files.meteor)) - .pipe(gulp.dest(outputDirectory)) + .on('end', function() { + gulp.src(manifest.assets) + .pipe(concatFileNames('empty.txt', concatSettings)) + .pipe(tap(function(file) { + filenames += file.contents; + })) + .on('end', function() { + filenames = filenames.replace(/,(?=[^,]*$)/, '').trim(); // remove trailing slash + gulp.src(release.templates.meteor.component) + .pipe(plumber()) + .pipe(flatten()) + .pipe(replace(regExp.match.name, regExp.replace.name)) + .pipe(replace(regExp.match.titleName, regExp.replace.titleName)) + .pipe(replace(regExp.match.version, version)) + .pipe(replace(regExp.match.files, filenames)) + .pipe(rename(release.files.meteor)) + .pipe(gulp.dest(outputDirectory)) + ; + }) ; }) ;