diff --git a/lib/__tests__/build-files.test.js b/lib/__tests__/build-files.test.js index 129756787975..e2b5b7ed0c59 100644 --- a/lib/__tests__/build-files.test.js +++ b/lib/__tests__/build-files.test.js @@ -28,7 +28,7 @@ let outputAssetsFiles = []; function generateSite() { shell.cd('website'); - shell.exec('yarn build'); + shell.exec('yarn build', {silent: true}); } function clearBuildFolder() { diff --git a/lib/server/__tests__/docs.test.js b/lib/server/__tests__/docs.test.js index 19ec0e7c1a11..6410b235f251 100644 --- a/lib/server/__tests__/docs.test.js +++ b/lib/server/__tests__/docs.test.js @@ -89,7 +89,8 @@ describe('getFile', () => { fs.existsSync = jest.fn().mockReturnValue(true); fs.readFileSync = jest.fn().mockImplementation(file => { const fakePath = file.replace(process.cwd().replace(/website$/, ''), ''); - return fakeContent[fakePath]; + const normalizedPath = fakePath.replace(/\\/g, '/'); + return fakeContent[normalizedPath]; }); test('docs does not exist', () => { diff --git a/lib/server/utils.js b/lib/server/utils.js index d93c71265b1e..1f353db9e122 100644 --- a/lib/server/utils.js +++ b/lib/server/utils.js @@ -17,8 +17,10 @@ function getSubDir(file, refDir) { } function getLanguage(file, refDir) { + const separator = escapeStringRegexp(path.sep); + const baseDir = escapeStringRegexp(path.basename(refDir)); const regexSubFolder = new RegExp( - `${escapeStringRegexp(path.basename(refDir))}/(.*?)/.*` + `${baseDir}${separator}(.*?)${separator}.*` ); const match = regexSubFolder.exec(file);