Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2016
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating new folder with gulp

    Hi there,

    I'm creating a tool to scaffold some projects and I would like to know if any of you work with slush generator and gulp before.

    When I run slush (my generator), I want the engine to create a folder calling the template I created.

    Basically, the folder that will be created, will have my css, js, html files inside.

    Any help it will be great.

    Kind regards,

    Fernando Fas

  2. #2
    New Coder
    Join Date
    May 2016
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Basically, this is my slushfiles.js

    /*
    * slush-atlasboiler
    * https://github.com/Fernando.Fas/slush-atlasboiler
    *
    * Copyright (c) 2016, Fernando Fas
    * Licensed under the MIT license.
    */

    'use strict';

    var gulp = require('gulp'),
    install = require('gulp-install'),
    conflict = require('gulp-conflict'),
    template = require('gulp-template'),
    rename = require('gulp-rename'),
    _ = require('underscore.string'),
    inquirer = require('inquirer'),
    path = require('path');

    function format(string) {
    var username = string.toLowerCase();
    return username.replace(/\s/g, '');
    }

    var defaults = (function () {
    var workingDirName = path.basename(process.cwd()),
    homeDir, osUserName, configFile, user;

    if (process.platform === 'win32') {
    homeDir = process.env.USERPROFILE;
    osUserName = process.env.USERNAME || path.basename(homeDir).toLowerCase();
    }
    else {
    homeDir = process.env.HOME || process.env.HOMEPATH;
    osUserName = homeDir && homeDir.split('/').pop() || 'root';
    }

    configFile = path.join(homeDir, '.gitconfig');
    user = {};

    if (require('fs').existsSync(configFile)) {
    user = require('iniparser').parseSync(configFile).user;
    }

    return {
    appName: workingDirName,
    userName: osUserName || format(user.name || ''),
    authorName: user.name || '',
    authorEmail: user.email || ''
    };
    })();

    gulp.task('default', function (done) {
    var prompts = [{
    name: 'appName',
    message: 'What is the banner name?',
    default: defaults.appName
    },{
    name: 'appWidth',
    message: 'What is the banner width?',
    default: defaults.appWidth
    },{
    name: 'appHeight',
    message: 'What is the banner height?',
    default: defaults.appHeight
    }];

    //Ask
    inquirer.prompt(prompts,
    function (answers) {
    if (!answers.moveon) {
    return done();
    }
    answers.appNameSlug = _.slugify(answers.appName);
    answers.appWidthSlug = _.slugify(answers.appWidth);
    answers.appHeightSlug = _.slugify(answers.appHeight);
    gulp.src(__dirname + '/templates/**')
    .pipe(template(answers))
    .pipe(rename(function (file) {
    if (file.basename[0] === '_') {
    file.basename = '.' + file.basename.slice(1);
    }
    }))
    .pipe(conflict('./'))
    .pipe(gulp.dest('./'))
    .pipe(install())
    .on('end', function () {
    done();
    });
    });
    });


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •