From a0887bbad729c2a7772937744375de8f0f159e36 Mon Sep 17 00:00:00 2001 From: jlukic Date: Wed, 22 Jul 2015 14:37:07 -0400 Subject: [PATCH] Wrap more async into tasks --- tasks/install.js | 118 ++++++++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/tasks/install.js b/tasks/install.js index 0ac2c8601..acbf3c85e 100644 --- a/tasks/install.js +++ b/tasks/install.js @@ -200,7 +200,7 @@ gulp.task('run setup', function() { }); -gulp.task('create install files', function() { +gulp.task('create install files', function(callback) { /*-------------- Exit Conditions @@ -232,7 +232,7 @@ gulp.task('create install files', function() { ; /*-------------- - PM Install + NPM Install ---------------*/ // Check if PM install @@ -314,6 +314,7 @@ gulp.task('create install files', function() { } + /*-------------- Site Theme ---------------*/ @@ -331,61 +332,77 @@ gulp.task('create install files', function() { Theme Config ---------------*/ - var - // determine path to site theme folder from theme config - // force CSS path variable to use forward slashes for paths - pathToSite = path.relative(path.resolve(installPaths.themeConfigFolder), path.resolve(installPaths.site)).replace(/\\/g,'/'), - siteVariable = "@siteFolder : '" + pathToSite + "/';" - ; + gulp.task('create theme.config', function() { + var + // determine path to site theme folder from theme config + // force CSS path variable to use forward slashes for paths + pathToSite = path.relative(path.resolve(installPaths.themeConfigFolder), path.resolve(installPaths.site)).replace(/\\/g,'/'), + siteVariable = "@siteFolder : '" + pathToSite + "/';" + ; - // rewrite site variable in theme.less - console.info('Adjusting @siteFolder to: ', pathToSite + '/'); + // rewrite site variable in theme.less + console.info('Adjusting @siteFolder to: ', pathToSite + '/'); - if(fs.existsSync(installPaths.themeConfig)) { - console.info('Modifying src/theme.config (LESS config)', installPaths.themeConfig); - gulp.src(installPaths.themeConfig) - .pipe(plumber()) - .pipe(replace(regExp.siteVariable, siteVariable)) - .pipe(gulp.dest(installPaths.themeConfigFolder)) - ; - } - else { - console.info('Creating src/theme.config (LESS config)', installPaths.themeConfig); - gulp.src(source.themeConfig) - .pipe(plumber()) - .pipe(rename({ extname : '' })) - .pipe(replace(regExp.siteVariable, siteVariable)) - .pipe(gulp.dest(installPaths.themeConfigFolder)) - ; - } + if(fs.existsSync(installPaths.themeConfig)) { + console.info('Modifying src/theme.config (LESS config)', installPaths.themeConfig); + return gulp.src(installPaths.themeConfig) + .pipe(plumber()) + .pipe(replace(regExp.siteVariable, siteVariable)) + .pipe(gulp.dest(installPaths.themeConfigFolder)) + ; + } + else { + console.info('Creating src/theme.config (LESS config)', installPaths.themeConfig); + return gulp.src(source.themeConfig) + .pipe(plumber()) + .pipe(rename({ extname : '' })) + .pipe(replace(regExp.siteVariable, siteVariable)) + .pipe(gulp.dest(installPaths.themeConfigFolder)) + ; + } + }); /*-------------- Semantic.json ---------------*/ - var - jsonConfig = install.createJSON(answers) - ; + gulp.task('create semantic.json', function() { - // adjust variables in theme.less - if( fs.existsSync(files.config) ) { - console.info('Extending config file (semantic.json)', installPaths.config); - gulp.src(installPaths.config) - .pipe(plumber()) - .pipe(rename(settings.rename.json)) // preserve file extension - .pipe(jsonEditor(jsonConfig)) - .pipe(gulp.dest(installPaths.configFolder)) - ; - } - else { - console.info('Creating config file (semantic.json)', installPaths.config); - gulp.src(source.config) - .pipe(plumber()) - .pipe(rename({ extname : '' })) // remove .template from ext - .pipe(jsonEditor(jsonConfig)) - .pipe(gulp.dest(installPaths.configFolder)) + var + jsonConfig = install.createJSON(answers) ; - } + + // adjust variables in theme.less + if( fs.existsSync(files.config) ) { + console.info('Extending config file (semantic.json)', installPaths.config); + return gulp.src(installPaths.config) + .pipe(plumber()) + .pipe(rename(settings.rename.json)) // preserve file extension + .pipe(jsonEditor(jsonConfig)) + .pipe(gulp.dest(installPaths.configFolder)) + ; + } + else { + console.info('Creating config file (semantic.json)', installPaths.config); + return gulp.src(source.config) + .pipe(plumber()) + .pipe(rename({ extname : '' })) // remove .template from ext + .pipe(jsonEditor(jsonConfig)) + .pipe(gulp.dest(installPaths.configFolder)) + ; + } + + }); + + runSequence( + 'create theme.config', + 'create semantic.json', + callback + ); + +}); + +gulp.task('clean up install', function() { // Completion Message if(installFolder) { @@ -396,11 +413,6 @@ gulp.task('create install files', function() { console.log(''); } - - -}); - -gulp.task('clean up install', function() { return gulp .src('gulpfile.js') .pipe(prompt.prompt(questions.cleanup, function(answers) {