From 241d8a24cfa3b8d762d05df0e6ae1abc26db68ea Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Mon, 1 Jun 2020 22:09:36 +0200 Subject: [PATCH 1/3] fix: fix windows path separator --- src/cli/htmlhint.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cli/htmlhint.ts b/src/cli/htmlhint.ts index 3a3557982..f7191a24b 100644 --- a/src/cli/htmlhint.ts +++ b/src/cli/htmlhint.ts @@ -6,6 +6,7 @@ import * as program from 'commander' import { existsSync, readFileSync, statSync } from 'fs' import * as glob from 'glob' import { IGlob } from 'glob' +import { type as osType } from 'os' import * as parseGlob from 'parse-glob' import { dirname, resolve, sep } from 'path' import * as request from 'request' @@ -19,6 +20,8 @@ const formatter: Formatter = require('./formatter') const pkg = require('../../package.json') +const OS_TYPE = osType() + function map(val: string) { const objMap: { [name: string]: string | true } = {} val.split(',').forEach((item) => { @@ -446,6 +449,11 @@ function walkPath( walk.on('match', (file: string) => { base = base.replace(/^.\//, '') + + if (OS_TYPE === 'Windows_NT') { + base = base.replace(/\//g, '\\') + } + callback(base + file) }) } From 8a4b1f9ab956900f9761b390e3d9489393d56ab8 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Mon, 1 Jun 2020 22:11:18 +0200 Subject: [PATCH 2/3] test: remove TODOs --- test/cli/formatters/compact.spec.js | 5 +---- test/cli/formatters/html.spec.js | 8 +------- test/cli/formatters/unix.spec.js | 5 +---- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/test/cli/formatters/compact.spec.js b/test/cli/formatters/compact.spec.js index 636f5cf4d..cd0f8d324 100644 --- a/test/cli/formatters/compact.spec.js +++ b/test/cli/formatters/compact.spec.js @@ -11,10 +11,7 @@ describe('CLI', () => { .readFileSync(path.resolve(__dirname, 'compact.txt'), 'utf8') .replace( /\{\{path\}\}/g, - path - .resolve(__dirname, '../../html/executable.html') - // TODO: we need to fix windows backslash - .replace('html\\executable.html', 'html/executable.html') + path.resolve(__dirname, '../../html/executable.html') ) .replace(/\\u001b/g, '\u001b') diff --git a/test/cli/formatters/html.spec.js b/test/cli/formatters/html.spec.js index 519b77883..67e38d171 100644 --- a/test/cli/formatters/html.spec.js +++ b/test/cli/formatters/html.spec.js @@ -9,13 +9,7 @@ describe('CLI', () => { it('should have stdout output with formatter html', (done) => { const expected = fs .readFileSync(path.resolve(__dirname, 'html.html'), 'utf8') - .replace( - /\{\{path\}\}/g, - path - .resolve(__dirname, 'example.html') - // TODO: we need to fix windows backslash - .replace('\\example', '/example') - ) + .replace(/\{\{path\}\}/g, path.resolve(__dirname, 'example.html')) const expectedParts = expected.split('\n') diff --git a/test/cli/formatters/unix.spec.js b/test/cli/formatters/unix.spec.js index 10f02e60a..bee9348b6 100644 --- a/test/cli/formatters/unix.spec.js +++ b/test/cli/formatters/unix.spec.js @@ -11,10 +11,7 @@ describe('CLI', () => { .readFileSync(path.resolve(__dirname, 'unix.txt'), 'utf8') .replace( /\{\{path\}\}/g, - path - .resolve(__dirname, '../../html/executable.html') - // TODO: we need to fix windows backslash - .replace('html\\executable.html', 'html/executable.html') + path.resolve(__dirname, '../../html/executable.html') ) .replace(/\\u001b/g, '\u001b') From ba2284aa07a4b1409f25ec83d3bf4df160a402af Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 25 Jun 2020 21:44:10 +0200 Subject: [PATCH 3/3] test: remove TODOs --- test/cli/formatters/checkstyle.spec.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/cli/formatters/checkstyle.spec.js b/test/cli/formatters/checkstyle.spec.js index 256117bf2..7ab2af9b7 100644 --- a/test/cli/formatters/checkstyle.spec.js +++ b/test/cli/formatters/checkstyle.spec.js @@ -9,13 +9,7 @@ describe('CLI', () => { it('should have stdout output with formatter checkstyle', (done) => { const expected = fs .readFileSync(path.resolve(__dirname, 'checkstyle.xml'), 'utf8') - .replace( - '{{path}}', - path - .resolve(__dirname, 'example.html') - // TODO: we need to fix windows backslash - .replace('\\example', '/example') - ) + .replace('{{path}}', path.resolve(__dirname, 'example.html')) const expectedParts = expected.split('\n')