mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-20 07:23:59 +08:00
Added input file type validation to Gulp pipelines.
This commit is contained in:
parent
c9c39b7e6a
commit
1b216bccdf
@ -78,9 +78,9 @@ function createAssetGroupTask(assetGroup, doRebuild) {
|
||||
var outputExt = path.extname(assetGroup.output).toLowerCase();
|
||||
switch (outputExt) {
|
||||
case ".css":
|
||||
return buildCssGroup(assetGroup, doRebuild);
|
||||
return buildCssPipeline(assetGroup, doRebuild);
|
||||
case ".js":
|
||||
return buildJsGroup(assetGroup, doRebuild);
|
||||
return buildJsPipeline(assetGroup, doRebuild);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,12 @@ function createAssetGroupTask(assetGroup, doRebuild) {
|
||||
** PROCESSING PIPELINES
|
||||
*/
|
||||
|
||||
function buildCssGroup(assetGroup, doRebuild) {
|
||||
function buildCssPipeline(assetGroup, doRebuild) {
|
||||
assetGroup.inputPaths.forEach(function (inputPath) {
|
||||
var ext = path.extname(inputPath).toLowerCase();
|
||||
if (ext !== ".less" && ext !== ".css")
|
||||
throw "Input file '" + inputPath + "' is not of a valid type for output file '" + assetGroup.outputPath + "'.";
|
||||
});
|
||||
var doConcat = path.basename(assetGroup.outputFileName, ".css") !== "@";
|
||||
return gulp.src(assetGroup.inputPaths)
|
||||
.pipe(gulpif(!doRebuild,
|
||||
@ -103,7 +108,7 @@ function buildCssGroup(assetGroup, doRebuild) {
|
||||
.pipe(gulpif("*.less", less()))
|
||||
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
||||
.pipe(autoprefixer({ browsers: ["last 2 versions"] }))
|
||||
// TODO: Use below when gulp-header supports sourcemaps.
|
||||
// TODO: Start using below whenever gulp-header supports sourcemaps.
|
||||
//.pipe(header(
|
||||
// "/*\n" +
|
||||
// "** NOTE: This file is generated by Gulp compilation and should not be edited directly!\n" +
|
||||
@ -119,7 +124,12 @@ function buildCssGroup(assetGroup, doRebuild) {
|
||||
.pipe(gulp.dest(assetGroup.outputDir));
|
||||
}
|
||||
|
||||
function buildJsGroup(assetGroup, doRebuild) {
|
||||
function buildJsPipeline(assetGroup, doRebuild) {
|
||||
assetGroup.inputPaths.forEach(function (inputPath) {
|
||||
var ext = path.extname(inputPath).toLowerCase();
|
||||
if (ext !== ".ts" && ext !== ".js")
|
||||
throw "Input file '" + inputPath + "' is not of a valid type for output file '" + assetGroup.outputPath + "'.";
|
||||
});
|
||||
var doConcat = path.basename(assetGroup.outputFileName, ".js") !== "@";
|
||||
return gulp.src(assetGroup.inputPaths)
|
||||
.pipe(gulpif(!doRebuild,
|
||||
@ -138,7 +148,7 @@ function buildJsGroup(assetGroup, doRebuild) {
|
||||
sortOutput: true,
|
||||
}).js))
|
||||
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
||||
// TODO: Use below when gulp-header supports sourcemaps.
|
||||
// TODO: Start using below whenever gulp-header supports sourcemaps.
|
||||
//.pipe(header(
|
||||
// "/*\n" +
|
||||
// "** NOTE: This file is generated by Gulp compilation and should not be edited directly!\n" +
|
||||
|
Loading…
Reference in New Issue
Block a user