Fix static asset building on Windows

Normalize all paths to have only forward slashes before mangling them.
This commit is contained in:
Aarni Koskela 2016-01-14 17:13:10 +02:00 committed by Karl Hobley
parent 62b996622a
commit 6f18c5ea0f
3 changed files with 18 additions and 3 deletions

View file

@ -0,0 +1,13 @@
var quoteRegExp = function (str) {
return (str + '').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
};
var re = new RegExp(quoteRegExp(require("path").sep), "g");
/**
* Normalize path separators to forward slashes
* @param path A path in either Windows or POSIX format
* @returns {string} A path in POSIX format
*/
module.exports = function (path) {
return ("" + path).replace(re, "/");
};

View file

@ -3,6 +3,7 @@ var rename = require('gulp-rename');
var gutil = require('gulp-util');
var path = require('path');
var config = require('../config');
var normalizePath = require('../lib/normalize-path');
/*
* Simple copy task - just copoes files from the source to the destination,
@ -12,7 +13,7 @@ var config = require('../config');
var renameSrcToDest = function() {
return rename(function(filePath) {
filePath.dirname = filePath.dirname.replace(
filePath.dirname = normalizePath(filePath.dirname).replace(
'/' + config.srcDir + '/',
'/' + config.destDir + '/');
});

View file

@ -3,6 +3,7 @@ var sass = require('gulp-sass');
var config = require('../config');
var autoprefixer = require('gulp-autoprefixer');
var simpleCopyTask = require('../lib/simplyCopy');
var normalizePath = require('../lib/normalize-path');
var gutil = require('gulp-util');
var flatten = function(arrOfArr) {
@ -38,9 +39,9 @@ gulp.task('styles:sass', function () {
.pipe(gulp.dest(function(file) {
// e.g. wagtailadmin/scss/core.scss -> wagtailadmin/css/core.css
// Changing the suffix is done by Sass automatically
return file.base
return normalizePath(file.base)
.replace(
'/' + config.srcDir + '/',
'/' + config.srcDir + '/',
'/' + config.destDir + '/'
)
.replace('/scss/', '/css/');