diff --git a/gulpfile.js b/gulpfile.js index 41a987d01098ff93b0e376c2059101530e954805..c3576981d910e0b3ca6cd4224505940db59e3c73 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -99,12 +99,20 @@ function tweeCompileCommand() { return `${tweeCompilerExecutable()} -f ${cfg.twineformat} --head=${cfg.sources.head} -o ${path.join(cfg.dirs.intermediate, htmlOut)} ${moduleArgs.join(' ')} ${sources.join(' ')}`; } +/** + * gulp-sort uses String.localeCompare() by default, which may be case-insensitive, + * while we require case -sensitive sorting for sources + */ +function pathcmp(a, b) { + return (a.path < b.path ? -1 : (a.path > b.path ? 1 : 0)); +} + /** * Creates a pipeline that sorts and combines files */ function concatFiles(srcGlob, destDir, destFileName) { return gulp.src(srcGlob) - .pipe(sort()) + .pipe(sort(pathcmp)) .pipe(concat(destFileName)) .pipe(gulp.dest(destDir)); } @@ -120,7 +128,7 @@ function processScripts(srcGlob, destDir, destFileName) { const addSourcemaps = !args.release; const prefix = path.relative(destDir, srcGlob.substr(0, srcGlob.indexOf('*'))); return gulp.src(srcGlob) - .pipe(sort()) + .pipe(sort(pathcmp)) .pipe(addSourcemaps ? sourcemaps.init() : noop()) .pipe(concat(destFileName)) .pipe(addSourcemaps ? @@ -144,7 +152,7 @@ function processStylesheets(srcGlob, destDir, destFileName) { const addSourcemaps = !args.release; const prefix = path.relative(destDir, srcGlob.substr(0, srcGlob.indexOf('*'))); return gulp.src(srcGlob) - .pipe(sort()) + .pipe(sort(pathcmp)) .pipe(addSourcemaps ? sourcemaps.init() : noop()) .pipe(concat(destFileName)) .pipe(cfg.options.css.autoprefix ? @@ -332,7 +340,7 @@ gulp.task('twineCSS', function() { gulp.task('twineJS', function() { return gulp.src([...cfg.sources.module.js, ...cfg.sources.story.js, '!src/art/assistantArt.js']) .pipe(stripCssJSComments({trim: true})) - .pipe(sort()) + .pipe(sort(pathcmp)) .pipe(concat('twine JS.txt')) .pipe(gulp.dest('devNotes')); });