Gulp重命名文件而不是目录

时间:2016-03-21 15:00:44

标签: javascript node.js gulp gulp-rename

function javascriptSites() {
  return gulp.src(PATHS.javascriptSites)
  .pipe($.sourcemaps.init())
  .pipe($.babel())
  .pipe($.if(PRODUCTION, $.uglify()
    .on('error', e => { console.log(e); })
  ))
  .pipe($.if(PRODUCTION, $.rename({
    suffix: '.min'  
  })))
  .pipe(gulp.dest('dist/assets/js'))
}

这是输出以下树:

dir/assets/js/

folder1
    site.min.js

folder1.min
    empty

folder2
    site.min.js

folder2.min
    empty

folder3
    site.min.js

folder3.min
    empty

我想只重命名文件而不是目录(而不是重复文件夹),但我无法想出如何过滤掉目录。任何帮助表示赞赏!

编辑:为Fabio

添加了config.yml文件
  # Your project's server will run on localhost:xxxx at this port
  PORT: 8000

  # Autoprefixer will make sure your CSS works with these browsers
  COMPATIBILITY:
    - "last 2 versions"
    - "ie >= 9"

  # UnCSS will use these settings
  UNCSS_OPTIONS:
    html:
      - "src/**/*.html"
    ignore:
      - !!js/regexp .foundation-mq
      - !!js/regexp ^\.is-.*

  # Gulp will reference these paths when it copies files
  PATHS:
    # Paths to static assets that aren't images, CSS, or JavaScript
    assets:
      - "src/assets/**/*"
      - "!src/assets/{img,js,scss}/**/*"
    fonts:
      - "bower_components/font-awesome/fonts/**/*"

    # Paths to Sass libraries, which can then be loaded with @import
    sass:
      - "bower_components/foundation-sites/scss"
      - "bower_components/motion-ui/src"
      - "src/assets/scss"

    # Paths to JavaScript libraries, which are compined into one file
    javascript:
     # Libraries requried by Foundation
      - "bower_components/jquery/dist/jquery.js"
      - "bower_components/what-input/what-input.js"
     # Core Foundation files
      - "bower_components/foundation-sites/js/foundation.core.js"
      - "bower_components/foundation-sites/js/foundation.util.*.js"
     # Individual Foundation components
     # If you aren't using a component, just remove it from the list
      - "bower_components/foundation-sites/js/foundation.abide.js"
      - "bower_components/foundation-sites/js/foundation.accordion.js"
      - "bower_components/foundation-sites/js/foundation.accordionMenu.js"
      - "bower_components/foundation-sites/js/foundation.drilldown.js"
      - "bower_components/foundation-sites/js/foundation.dropdown.js"
      - "bower_components/foundation-sites/js/foundation.dropdownMenu.js"
      - "bower_components/foundation-sites/js/foundation.equalizer.js"
      - "bower_components/foundation-sites/js/foundation.interchange.js"
      - "bower_components/foundation-sites/js/foundation.magellan.js"
      - "bower_components/foundation-sites/js/foundation.offcanvas.js"
      - "bower_components/foundation-sites/js/foundation.orbit.js"
      - "bower_components/foundation-sites/js/foundation.responsiveMenu.js"
      - "bower_components/foundation-sites/js/foundation.responsiveToggle.js"
      - "bower_components/foundation-sites/js/foundation.reveal.js"
      - "bower_components/foundation-sites/js/foundation.slider.js"
      - "bower_components/foundation-sites/js/foundation.sticky.js"
      - "bower_components/foundation-sites/js/foundation.tabs.js"
      - "bower_components/foundation-sites/js/foundation.toggler.js"
      - "bower_components/foundation-sites/js/foundation.tooltip.js"
     # Paths to your own project code are here
      - "src/assets/js/!(app).js"
      - "src/assets/js/app.js"
      - "bower_components/owl.carousel/dist/owl.carousel.js"

     javascriptSites:
      - "src/assets/js/**/*"
      - "!src/assets/js/app.js"

1 个答案:

答案 0 :(得分:1)

问题出在您的.yml文件中。您将此指定为源:

sqlContext.sql("SELECT array FROM df").rdd.map{
  row =>  row.getList[Int](0).toArray
}.collect()

现在重命名和更改文件夹的原因是因为您将javascriptSites: - "src/assets/js/**/*" - "!src/assets/js/app.js" 内的所有内容传递到您的gulp管道,当您明确要求传递所有的javascript文件。

为此,您需要将 .yml 文件更改为:

src/assets/js/

请注意,我们在您的第一行添加了 .js ,因此gulp只会提供javascript文件,而不是文件夹。