Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/cli/htmlhint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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) => {
Expand Down Expand Up @@ -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)
})
}
Expand Down
8 changes: 1 addition & 7 deletions test/cli/formatters/checkstyle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
5 changes: 1 addition & 4 deletions test/cli/formatters/compact.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
8 changes: 1 addition & 7 deletions test/cli/formatters/html.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
5 changes: 1 addition & 4 deletions test/cli/formatters/unix.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down