From 0bd3d5ed586d748677f6d9a9ad3f133ae3dcd6c2 Mon Sep 17 00:00:00 2001 From: Mirko Kruschke Date: Tue, 22 Dec 2020 21:02:20 +0100 Subject: [PATCH] fix!: use posix file path style for reference paths --- package.json | 2 +- src/update-ts-references.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fe81dff..07be23b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "update-ts-references", - "version": "1.3.0", + "version": "2.0.0", "bin": "src/index.js", "scripts": { "lint": "eslint src tests", diff --git a/src/update-ts-references.js b/src/update-ts-references.js index f586a53..3a391ef 100644 --- a/src/update-ts-references.js +++ b/src/update-ts-references.js @@ -99,12 +99,18 @@ const getReferencesFromDependencies = ( .sort((refA, refB) => (refA.path > refB.path ? 1 : -1)); }; +const ensurePosixPathStyle = (reference) => ({ + ...reference, + path: reference.path.split(path.sep).join(path.posix.sep), +}); + const updateTsConfig = ( - references, + win32OrPosixReferences, discardComments, check, { packageDir } = { packageDir: process.cwd() } ) => { + const references = (win32OrPosixReferences || []).map(ensurePosixPathStyle); const tsconfigFilePath = path.join(packageDir, TS_CONFIG_JSON); let pureJson = true; try { @@ -131,7 +137,7 @@ Do you want to discard them and proceed?` } let isEqual = false; try { - assert.deepEqual(config.references || [], references || []); + assert.deepEqual(config.references || [], references); isEqual = true; } catch { // ignore me