lib/page.js
function copyFile(opts) {
    var importStr, ext;

    if (!opts) return console.log('incomplete options');
    ext = opts.ext;
    if (typeof ext === 'string') {
      ext = [ext]; // turn string ext into array
    }

    // itterate through each file and process it
    ext.forEach(function(extension) {
      var filename;

      filename = opts.filename;

      // handle sass paritals by prepending underscore
      if (extension === '.scss') {
        importStr = "@import '../pages/" + opts.pageName + "/" + filename + "';\n"
        fs.appendFileSync('client/styles/_pages.scss', importStr)
        filename = "_" + filename;
      }

      // copy from default folder to destination folder and rename any
      // variables that may be in each file
      fs.copy(opts.from + filename + extension,
              opts.to   + filename + extension, function (err) {

        handleError(err);

        replace(opts.to + filename + extension, function(data) {
          var res, repl;
          if (opts.replaceWith) {
            repl = opts.replaceWith;
            res = data.replace(/compName/g, changeCase.camelCase(repl));
            return res.replace(/comp-name/g, changeCase.paramCase(repl));
          } else {
            res = data.replace(/compName/g, nameCase.camel);
            return res.replace(/comp-name/g, nameCase.hyphen);
          }
        });

        console.log('    Created:', opts.to+opts.filename+extension);
      });

    });

  }
function copyFile(opts) {
    var importStr, ext;

    if (!opts) return console.log('incomplete options');
    ext = opts.ext;
    if (typeof ext === 'string') {
      ext = [ext]; // turn string ext into array
    }

    // itterate through each file and process it
    ext.forEach(function(extension) {
      var filename;

      filename = opts.filename;

      // handle sass paritals by prepending underscore
      if (extension === '.scss') {
        importStr = "@import '../pages/" + opts.pageName + "/" + filename + "';\n"
        fs.appendFileSync('client/styles/_pages.scss', importStr)
        filename = "_" + filename;
      }

      // copy from default folder to destination folder and rename any
      // variables that may be in each file
      fs.copy(opts.from + filename + extension,
              opts.to   + filename + extension, function (err) {

        handleError(err);

        replace(opts.to + filename + extension, function(data) {
          var res, repl;
          if (opts.replaceWith) {
            repl = opts.replaceWith;
            res = data.replace(/compName/g, changeCase.camelCase(repl));
            return res.replace(/comp-name/g, changeCase.paramCase(repl));
          } else {
            res = data.replace(/compName/g, nameCase.camel);
            return res.replace(/comp-name/g, nameCase.hyphen);
          }
        });

        console.log('    Created:', opts.to+opts.filename+extension);
      });

    });

  }
function copyFile ( opts ) { var importStr , ext ; if ( ! opts ) return console . log ( 'incomplete options' ) ; ext = opts . ext ; if ( typeof ext === 'string' ) { ext = [ ext ] ; // turn string ext into array } // itterate through each file and process it ext . forEach ( function ( extension ) { var filename ; filename = opts . filename ; // handle sass paritals by prepending underscore if ( extension === '.scss' ) { importStr = "@import '../pages/" + opts . pageName + "/" + filename + "';\n" fs . appendFileSync ( 'client/styles/_pages.scss' , importStr ) filename = "_" + filename ; } // copy from default folder to destination folder and rename any // variables that may be in each file fs . copy ( opts . from + filename + extension , opts . to + filename + extension , function ( err ) { handleError ( err ) ; replace ( opts . to + filename + extension , function ( data ) { var res , repl ; if ( opts . replaceWith ) { repl = opts . replaceWith ; res = data . replace ( / compName / g , changeCase . camelCase ( repl ) ) ; return res . replace ( / comp-name / g , changeCase . paramCase ( repl ) ) ; } else { res = data . replace ( / compName / g , nameCase . camel ) ; return res . replace ( / comp-name / g , nameCase . hyphen ) ; } } ) ; console . log ( '    Created:' , opts . to + opts . filename + extension ) ; } ) ; } ) ; }
Refactor into module ------------------------------------------
Refactor into module ------------------------------------------