File tree 5 files changed +12
-22
lines changed
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'
6
6
import { existsSync , readFileSync , statSync } from 'fs'
7
7
import * as glob from 'glob'
8
8
import { IGlob } from 'glob'
9
+ import { type as osType } from 'os'
9
10
import * as parseGlob from 'parse-glob'
10
11
import { dirname , resolve , sep } from 'path'
11
12
import * as request from 'request'
@@ -19,6 +20,8 @@ const formatter: Formatter = require('./formatter')
19
20
20
21
const pkg = require ( '../../package.json' )
21
22
23
+ const OS_TYPE = osType ( )
24
+
22
25
function map ( val : string ) {
23
26
const objMap : { [ name : string ] : string | true } = { }
24
27
val . split ( ',' ) . forEach ( ( item ) => {
@@ -446,6 +449,11 @@ function walkPath(
446
449
447
450
walk . on ( 'match' , ( file : string ) => {
448
451
base = base . replace ( / ^ .\/ / , '' )
452
+
453
+ if ( OS_TYPE === 'Windows_NT' ) {
454
+ base = base . replace ( / \/ / g, '\\' )
455
+ }
456
+
449
457
callback ( base + file )
450
458
} )
451
459
}
Original file line number Diff line number Diff line change @@ -9,13 +9,7 @@ describe('CLI', () => {
9
9
it ( 'should have stdout output with formatter checkstyle' , ( done ) => {
10
10
const expected = fs
11
11
. 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' ) )
19
13
20
14
const expectedParts = expected . split ( '\n' )
21
15
Original file line number Diff line number Diff line change @@ -11,10 +11,7 @@ describe('CLI', () => {
11
11
. readFileSync ( path . resolve ( __dirname , 'compact.txt' ) , 'utf8' )
12
12
. replace (
13
13
/ \{ \{ 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' )
18
15
)
19
16
. replace ( / \\ u 0 0 1 b / g, '\u001b' )
20
17
Original file line number Diff line number Diff line change @@ -9,13 +9,7 @@ describe('CLI', () => {
9
9
it ( 'should have stdout output with formatter html' , ( done ) => {
10
10
const expected = fs
11
11
. 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' ) )
19
13
20
14
const expectedParts = expected . split ( '\n' )
21
15
Original file line number Diff line number Diff line change @@ -11,10 +11,7 @@ describe('CLI', () => {
11
11
. readFileSync ( path . resolve ( __dirname , 'unix.txt' ) , 'utf8' )
12
12
. replace (
13
13
/ \{ \{ 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' )
18
15
)
19
16
. replace ( / \\ u 0 0 1 b / g, '\u001b' )
20
17
You can’t perform that action at this time.
0 commit comments