diff --git a/ghost/minifier/lib/Minifier.js b/ghost/minifier/lib/Minifier.js index 18cf5891a83..59168e29b15 100644 --- a/ghost/minifier/lib/Minifier.js +++ b/ghost/minifier/lib/Minifier.js @@ -4,6 +4,7 @@ const tpl = require('@tryghost/tpl'); const glob = require('tiny-glob'); const path = require('path'); const fs = require('fs').promises; +const isWin = process.platform === 'win32'; const messages = { badDestination: { @@ -69,7 +70,11 @@ class Minifier { } async getMatchingFiles(src) { - return await glob(this.getFullSrc(src)); + let fullSrc = this.getFullSrc(src); + if (isWin) { + fullSrc = fullSrc.replace(/\\/g,'/'); + } + return await glob(fullSrc); } async readFiles(files) { diff --git a/ghost/minifier/test/minifier.test.js b/ghost/minifier/test/minifier.test.js index f79896d8b4e..a084c11c714 100644 --- a/ghost/minifier/test/minifier.test.js +++ b/ghost/minifier/test/minifier.test.js @@ -28,31 +28,31 @@ describe('Minifier', function () { let result = await minifier.getMatchingFiles('css/*.css'); result.should.be.an.Array().with.lengthOf(3); - result[0].should.eql('test/fixtures/basic-cards/css/bookmark.css'); - result[1].should.eql('test/fixtures/basic-cards/css/empty.css'); - result[2].should.eql('test/fixtures/basic-cards/css/gallery.css'); + result[0].should.eql(path.join('test','fixtures','basic-cards','css','bookmark.css')); + result[1].should.eql(path.join('test','fixtures','basic-cards','css','empty.css')); + result[2].should.eql(path.join('test','fixtures','basic-cards','css','gallery.css')); }); it('match glob range e.g. css/bookmark.css and css/empty.css (css/@(bookmark|empty).css)', async function () { let result = await minifier.getMatchingFiles('css/@(bookmark|empty).css'); result.should.be.an.Array().with.lengthOf(2); - result[0].should.eql('test/fixtures/basic-cards/css/bookmark.css'); - result[1].should.eql('test/fixtures/basic-cards/css/empty.css'); + result[0].should.eql(path.join('test','fixtures','basic-cards','css','bookmark.css')); + result[1].should.eql(path.join('test','fixtures','basic-cards','css','empty.css')); }); it('reverse match glob e.g. css/!(bookmark).css', async function () { let result = await minifier.getMatchingFiles('css/!(bookmark).css'); result.should.be.an.Array().with.lengthOf(2); - result[0].should.eql('test/fixtures/basic-cards/css/empty.css'); - result[1].should.eql('test/fixtures/basic-cards/css/gallery.css'); + result[0].should.eql(path.join('test','fixtures','basic-cards','css','empty.css')); + result[1].should.eql(path.join('test','fixtures','basic-cards','css','gallery.css')); }); it('reverse match glob e.g. css/!(bookmark|gallery).css', async function () { let result = await minifier.getMatchingFiles('css/!(bookmark|gallery).css'); result.should.be.an.Array().with.lengthOf(1); - result[0].should.eql('test/fixtures/basic-cards/css/empty.css'); + result[0].should.eql(path.join('test','fixtures','basic-cards','css','empty.css')); }); });