1
1
import test from 'ava'
2
2
import { execSync } from 'child_process'
3
3
import { readFileSync , unlinkSync , readdirSync , existsSync , lstatSync } from 'fs'
4
- import { resolve , join } from 'path'
4
+ import { resolve , posix } from 'path'
5
5
import rimraf = require( 'rimraf' )
6
6
7
7
export function run ( ) {
@@ -84,7 +84,7 @@ export function run() {
84
84
} )
85
85
86
86
test ( 'files in (-i), files out (-o)' , t => {
87
- execSync ( " node dist/src/cli.js -i ' ./test/resources/MultiSchema/**/*.json' -o ./test/resources/MultiSchema/out" )
87
+ execSync ( ` node dist/src/cli.js -i " ./test/resources/MultiSchema/**/*.json" -o ./test/resources/MultiSchema/out` )
88
88
89
89
readdirSync ( './test/resources/MultiSchema/out' ) . forEach ( f => {
90
90
const path = `./test/resources/MultiSchema/out/${ f } `
@@ -96,12 +96,12 @@ export function run() {
96
96
} )
97
97
98
98
test ( 'files in (-i), pipe out' , t => {
99
- t . snapshot ( execSync ( " node dist/src/cli.js -i ' ./test/resources/MultiSchema/**/*.json'" ) . toString ( ) )
99
+ t . snapshot ( execSync ( ` node dist/src/cli.js -i " ./test/resources/MultiSchema/**/*.json"` ) . toString ( ) )
100
100
} )
101
101
102
102
test ( 'files in (-i), files out (-o) nested dir does not exist' , t => {
103
103
execSync (
104
- " node dist/src/cli.js -i ' ./test/resources/MultiSchema/**/*.json' -o ./test/resources/MultiSchema/foo/bar/out"
104
+ ` node dist/src/cli.js -i " ./test/resources/MultiSchema/**/*.json" -o ./test/resources/MultiSchema/foo/bar/out`
105
105
)
106
106
readdirSync ( './test/resources/MultiSchema/foo/bar/out' ) . forEach ( f => {
107
107
const path = `./test/resources/MultiSchema/foo/bar/out/${ f } `
@@ -114,7 +114,7 @@ export function run() {
114
114
115
115
test ( 'files in (-i), files out (-o) matching nested dir' , t => {
116
116
execSync (
117
- " node dist/src/cli.js -i ' ./test/resources/../../test/resources/MultiSchema2/' -o ./test/resources/MultiSchema2/out"
117
+ ` node dist/src/cli.js -i " ./test/resources/../../test/resources/MultiSchema2/" -o ./test/resources/MultiSchema2/out`
118
118
)
119
119
getPaths ( './test/resources/MultiSchema2/out' ) . forEach ( file => {
120
120
t . snapshot ( file )
@@ -127,10 +127,11 @@ export function run() {
127
127
128
128
function getPaths ( path : string , paths : string [ ] = [ ] ) {
129
129
if ( existsSync ( path ) && lstatSync ( path ) . isDirectory ( ) ) {
130
- readdirSync ( resolve ( path ) ) . forEach ( item => getPaths ( join ( path , item ) , paths ) )
130
+ readdirSync ( resolve ( path ) ) . forEach ( item => getPaths ( posix . join ( posix . normalize ( path ) , item ) , paths ) )
131
131
} else {
132
132
paths . push ( path )
133
133
}
134
134
135
- return paths
135
+ // sort paths to ensure a stable order across environments
136
+ return paths . sort ( ( a , b ) => a . localeCompare ( b ) )
136
137
}
0 commit comments