Skip to content
This repository was archived by the owner on Nov 14, 2022. It is now read-only.

Commit 8fa728e

Browse files
committed
🩹Only use posix paths for cross platform compatibility
1 parent d348981 commit 8fa728e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {deburr, isPlainObject, trim, upperFirst} from 'lodash'
2-
import {basename, dirname, extname, join, normalize, sep} from 'path'
2+
import {basename, dirname, extname, normalize, sep, posix} from 'path'
33
import {JSONSchema, LinkedJSONSchema, Parent} from './types/JSONSchema'
44

55
// TODO: pull out into a separate package
@@ -274,7 +274,7 @@ export function pathTransform(outputPath: string, inputPath: string, filePath: s
274274
const filePathList = dirname(normalize(filePath)).split(sep)
275275
const filePathRel = filePathList.filter((f, i) => f !== inPathList[i])
276276

277-
return join(normalize(outputPath), ...filePathRel)
277+
return posix.join(posix.normalize(outputPath), ...filePathRel)
278278
}
279279

280280
/**

test/testCLI.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import test from 'ava'
22
import {execSync} from 'child_process'
33
import {readFileSync, unlinkSync, readdirSync, existsSync, lstatSync} from 'fs'
4-
import {resolve, join} from 'path'
4+
import {resolve, posix} from 'path'
55
import rimraf = require('rimraf')
66

77
export function run() {
@@ -127,7 +127,7 @@ export function run() {
127127

128128
function getPaths(path: string, paths: string[] = []) {
129129
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))
131131
} else {
132132
paths.push(path)
133133
}

0 commit comments

Comments
 (0)