File tree Expand file tree Collapse file tree 5 files changed +12
-22
lines changed
Expand file tree Collapse file tree 5 files changed +12
-22
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import * as program from 'commander'
66import { existsSync , readFileSync , statSync } from 'fs'
77import * as glob from 'glob'
88import { IGlob } from 'glob'
9+ import { type as osType } from 'os'
910import * as parseGlob from 'parse-glob'
1011import { dirname , resolve , sep } from 'path'
1112import * as request from 'request'
@@ -19,6 +20,8 @@ const formatter: Formatter = require('./formatter')
1920
2021const pkg = require ( '../../package.json' )
2122
23+ const OS_TYPE = osType ( )
24+
2225function map ( val : string ) {
2326 const objMap : { [ name : string ] : string | true } = { }
2427 val . split ( ',' ) . forEach ( ( item ) => {
@@ -446,6 +449,11 @@ function walkPath(
446449
447450 walk . on ( 'match' , ( file : string ) => {
448451 base = base . replace ( / ^ .\/ / , '' )
452+
453+ if ( OS_TYPE === 'Windows_NT' ) {
454+ base = base . replace ( / \/ / g, '\\' )
455+ }
456+
449457 callback ( base + file )
450458 } )
451459}
Original file line number Diff line number Diff line change @@ -9,13 +9,7 @@ describe('CLI', () => {
99 it ( 'should have stdout output with formatter checkstyle' , ( done ) => {
1010 const expected = fs
1111 . readFileSync ( path . resolve ( __dirname , 'checkstyle.xml' ) , 'utf8' )
12- . replace (
13- '{{path}}' ,
14- path
15- . resolve ( __dirname , 'example.html' )
16- // TODO: we need to fix windows backslash
17- . replace ( '\\example' , '/example' )
18- )
12+ . replace ( '{{path}}' , path . resolve ( __dirname , 'example.html' ) )
1913
2014 const expectedParts = expected . split ( '\n' )
2115
Original file line number Diff line number Diff line change @@ -11,10 +11,7 @@ describe('CLI', () => {
1111 . readFileSync ( path . resolve ( __dirname , 'compact.txt' ) , 'utf8' )
1212 . replace (
1313 / \{ \{ p a t h \} \} / g,
14- path
15- . resolve ( __dirname , '../../html/executable.html' )
16- // TODO: we need to fix windows backslash
17- . replace ( 'html\\executable.html' , 'html/executable.html' )
14+ path . resolve ( __dirname , '../../html/executable.html' )
1815 )
1916 . replace ( / \\ u 0 0 1 b / g, '\u001b' )
2017
Original file line number Diff line number Diff line change @@ -9,13 +9,7 @@ describe('CLI', () => {
99 it ( 'should have stdout output with formatter html' , ( done ) => {
1010 const expected = fs
1111 . readFileSync ( path . resolve ( __dirname , 'html.html' ) , 'utf8' )
12- . replace (
13- / \{ \{ p a t h \} \} / g,
14- path
15- . resolve ( __dirname , 'example.html' )
16- // TODO: we need to fix windows backslash
17- . replace ( '\\example' , '/example' )
18- )
12+ . replace ( / \{ \{ p a t h \} \} / g, path . resolve ( __dirname , 'example.html' ) )
1913
2014 const expectedParts = expected . split ( '\n' )
2115
Original file line number Diff line number Diff line change @@ -11,10 +11,7 @@ describe('CLI', () => {
1111 . readFileSync ( path . resolve ( __dirname , 'unix.txt' ) , 'utf8' )
1212 . replace (
1313 / \{ \{ p a t h \} \} / g,
14- path
15- . resolve ( __dirname , '../../html/executable.html' )
16- // TODO: we need to fix windows backslash
17- . replace ( 'html\\executable.html' , 'html/executable.html' )
14+ path . resolve ( __dirname , '../../html/executable.html' )
1815 )
1916 . replace ( / \\ u 0 0 1 b / g, '\u001b' )
2017
You can’t perform that action at this time.
0 commit comments