Javascript 如何使用gulp检查文件名?

Javascript 如何使用gulp检查文件名?,javascript,gulp,Javascript,Gulp,下面是我正在使用的代码以及我思考解决方案的方式 gulp.task('templates:components', function () { log('Building components..'); //if (filename === 'app.jade') { // return gulp.src()..... // } else return gulp.src(source.templates.components) .pipe($.if(!isProduc

下面是我正在使用的代码以及我思考解决方案的方式

gulp.task('templates:components', function () {
log('Building components..');
//if (filename === 'app.jade') {
//  return gulp.src().....
// } else 
    return gulp.src(source.templates.components)
        .pipe($.if(!isProduction, $.changed(build.templates.views, {extension: '.html'})))
        .pipe($.jade())
        .on('error', handleError)
        .pipe($.htmlPrettify(prettifyOpts))
        .pipe(flatten({ includeParents: 1} ))
        .pipe(gulp.dest(build.templates.views + 'views'));
});
我不知道如何设置我的逻辑来检测文件,我已经搜索过了,但还没有找到一个明确的例子或插件来实现这一点


如何根据文件名确定目标的结果

我用“大口压扁”来选择我想要的路径部分

var source = {
scripts: [paths.scripts + 'app.module.js',
    // template modules
    paths.scripts + 'modules/**/*.module.js',
    paths.scripts + 'modules/**/**/*.js',
    // custom modules
    paths.scripts + 'components/**/*.module.js',
    paths.scripts + 'components/**/*.js'
],
templates: {
    components: [paths.components + '**/views/**/*.jade', paths.components + '**/**/**/*.jade']
},
styles: {
    app: [paths.styles + '*.*'],
    themes: [paths.styles + 'themes/*'],
    watch: [paths.styles + '**/*', '!' + paths.styles + 'themes/*']
},
images: paths.images
};

// BUILD TARGET CONFIG 
    var build = {
    scripts: paths.app + 'js',
    styles: paths.app + 'css',
    templates: {
    index: '../',
    views: paths.app,
    cache: paths.app + 'js/' + 'templates.js',
},
images: paths.app + 'img'
};

gulp.task('templates:components', function () {
log('Building components..');
    return gulp.src(source.templates.components)
        .pipe($.if(!isProduction, $.changed(build.templates.views,    {extension: '.html'})))
        .pipe($.jade())
        .on('error', handleError)
        .pipe($.htmlPrettify(prettifyOpts))
        .pipe(flatten({ includeParents: 1} ))
        .pipe(gulp.dest(build.templates.views + 'views'));
});

你能解释一下你想要实现什么吗?您是否只想创建一个包并将其放入目标文件夹(您要指定的文件夹)?昨晚我想出了一个解决方案。