Skip to content

Commit

Permalink
fix(windows): normalize paths
Browse files Browse the repository at this point in the history
  • Loading branch information
huafu committed Sep 20, 2018
1 parent 0141098 commit c12dfff
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 60 deletions.
2 changes: 1 addition & 1 deletion e2e/__helpers__/test-case/run-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class RunResult {
}
get cmdLine() {
return [this.context.cmd, ...this.context.args]
.filter(a => !['-u', '--updateSnapshot', '--runInBand'].includes(a))
.filter(a => !['-u', '--updateSnapshot', '--runInBand', '--'].includes(a))
.join(' ')
}

Expand Down
31 changes: 13 additions & 18 deletions e2e/__tests__/__snapshots__/hoisting.test.ts.snap

Large diffs are not rendered by default.

31 changes: 13 additions & 18 deletions e2e/__tests__/__snapshots__/source-map.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ exports[`using template "default" should have the source maps comment 1`] = `
throw new Error('WITHIN SOURCE');
}
exports.throwError = throwError;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoibWFpbi50cyIsIm1hcHBpbmdzIjoiOztBQUFBLFNBQWdCLFVBQVU7SUFDeEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsQ0FBQTtBQUM5QixDQUFDO0FBRkQsZ0NBRUM7QUFFRCxTQUFnQixVQUFVO0lBQ3hCLE1BQU0sSUFBSSxLQUFLLENBQUMsZUFBZSxDQUFDLENBQUE7QUFDbEMsQ0FBQztBQUZELGdDQUVDIiwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiPGN3ZD4vIiwic291cmNlcyI6WyJtYWluLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBjb25zb2xlTG9nKCkge1xuICBjb25zb2xlLmxvZygnV0lUSElOIFNPVVJDRScpXG59XG5cbmV4cG9ydCBmdW5jdGlvbiB0aHJvd0Vycm9yKCkge1xuICB0aHJvdyBuZXcgRXJyb3IoJ1dJVEhJTiBTT1VSQ0UnKVxufVxuIl0sInZlcnNpb24iOjN9
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiPGN3ZD4vbWFpbi50cyIsIm1hcHBpbmdzIjoiOztBQUFBLFNBQWdCLFVBQVU7SUFDeEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsQ0FBQTtBQUM5QixDQUFDO0FBRkQsZ0NBRUM7QUFFRCxTQUFnQixVQUFVO0lBQ3hCLE1BQU0sSUFBSSxLQUFLLENBQUMsZUFBZSxDQUFDLENBQUE7QUFDbEMsQ0FBQztBQUZELGdDQUVDIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbIjxjd2Q+L21haW4udHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGNvbnNvbGVMb2coKSB7XG4gIGNvbnNvbGUubG9nKCdXSVRISU4gU09VUkNFJylcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHRocm93RXJyb3IoKSB7XG4gIHRocm93IG5ldyBFcnJvcignV0lUSElOIFNPVVJDRScpXG59XG4iXSwidmVyc2lvbiI6M30=
===[ INLINE SOURCE MAPS ]=======================================================
file: main.ts
file: <cwd>/main.ts
mappings: >-
;;AAAA,SAAgB,UAAU;IACxB,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAC9B,CAAC;AAFD,gCAEC;AAED,SAAgB,UAAU;IACxB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;AAClC,CAAC;AAFD,gCAEC
names: []
sourceRoot: <cwd>/
sources:
- main.ts
- <cwd>/main.ts
sourcesContent:
- |
export function consoleLog() {
Expand Down Expand Up @@ -101,14 +100,13 @@ exports[`using template "with-babel-6" should have the source maps comment 1`] =
throw new Error('WITHIN SOURCE');
}
exports.throwError = throwError;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJtYXBwaW5ncyI6Ijs7O0FBQUEsU0FBZ0IsVUFBaEIsR0FBMEI7QUFDeEIsWUFBUSxHQUFSLENBQVksZUFBWjtBQUNEO0FBRkQsUUFBQSxVQUFBLEdBQUEsVUFBQTtBQUlBLFNBQWdCLFVBQWhCLEdBQTBCO0FBQ3hCLFVBQU0sSUFBSSxLQUFKLENBQVUsZUFBVixDQUFOO0FBQ0Q7QUFGRCxRQUFBLFVBQUEsR0FBQSxVQUFBIiwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiPGN3ZD4vIiwic291cmNlcyI6WyJtYWluLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBjb25zb2xlTG9nKCkge1xuICBjb25zb2xlLmxvZygnV0lUSElOIFNPVVJDRScpXG59XG5cbmV4cG9ydCBmdW5jdGlvbiB0aHJvd0Vycm9yKCkge1xuICB0aHJvdyBuZXcgRXJyb3IoJ1dJVEhJTiBTT1VSQ0UnKVxufVxuIl0sInZlcnNpb24iOjN9
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJtYXBwaW5ncyI6Ijs7O0FBQUEsU0FBZ0IsVUFBaEIsR0FBMEI7QUFDeEIsWUFBUSxHQUFSLENBQVksZUFBWjtBQUNEO0FBRkQsUUFBQSxVQUFBLEdBQUEsVUFBQTtBQUlBLFNBQWdCLFVBQWhCLEdBQTBCO0FBQ3hCLFVBQU0sSUFBSSxLQUFKLENBQVUsZUFBVixDQUFOO0FBQ0Q7QUFGRCxRQUFBLFVBQUEsR0FBQSxVQUFBIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbIjxjd2Q+L21haW4udHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGNvbnNvbGVMb2coKSB7XG4gIGNvbnNvbGUubG9nKCdXSVRISU4gU09VUkNFJylcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHRocm93RXJyb3IoKSB7XG4gIHRocm93IG5ldyBFcnJvcignV0lUSElOIFNPVVJDRScpXG59XG4iXSwidmVyc2lvbiI6M30=
===[ INLINE SOURCE MAPS ]=======================================================
mappings: >-
;;;AAAA,SAAgB,UAAhB,GAA0B;AACxB,YAAQ,GAAR,CAAY,eAAZ;AACD;AAFD,QAAA,UAAA,GAAA,UAAA;AAIA,SAAgB,UAAhB,GAA0B;AACxB,UAAM,IAAI,KAAJ,CAAU,eAAV,CAAN;AACD;AAFD,QAAA,UAAA,GAAA,UAAA
names: []
sourceRoot: <cwd>/
sources:
- main.ts
- <cwd>/main.ts
sourcesContent:
- |
export function consoleLog() {
Expand Down Expand Up @@ -195,14 +193,13 @@ exports[`using template "with-babel-7" should have the source maps comment 1`] =
}
exports.throwError = throwError;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsU0FBZ0IsVUFBaEIsR0FBMEI7QUFDeEIsRUFBQSxPQUFPLENBQUMsR0FBUixDQUFZLGVBQVo7QUFDRDs7QUFGRCxPQUFBLENBQUEsVUFBQSxHQUFBLFVBQUE7O0FBSUEsU0FBZ0IsVUFBaEIsR0FBMEI7QUFDeEIsUUFBTSxJQUFJLEtBQUosQ0FBVSxlQUFWLENBQU47QUFDRDs7QUFGRCxPQUFBLENBQUEsVUFBQSxHQUFBLFVBQUEiLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiI8Y3dkPi8iLCJzb3VyY2VzIjpbIm1haW4udHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGNvbnNvbGVMb2coKSB7XG4gIGNvbnNvbGUubG9nKCdXSVRISU4gU09VUkNFJylcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHRocm93RXJyb3IoKSB7XG4gIHRocm93IG5ldyBFcnJvcignV0lUSElOIFNPVVJDRScpXG59XG4iXSwidmVyc2lvbiI6M30=
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsU0FBZ0IsVUFBaEIsR0FBMEI7QUFDeEIsRUFBQSxPQUFPLENBQUMsR0FBUixDQUFZLGVBQVo7QUFDRDs7QUFGRCxPQUFBLENBQUEsVUFBQSxHQUFBLFVBQUE7O0FBSUEsU0FBZ0IsVUFBaEIsR0FBMEI7QUFDeEIsUUFBTSxJQUFJLEtBQUosQ0FBVSxlQUFWLENBQU47QUFDRDs7QUFGRCxPQUFBLENBQUEsVUFBQSxHQUFBLFVBQUEiLCJuYW1lcyI6W10sInNvdXJjZXMiOlsiPGN3ZD4vbWFpbi50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gY29uc29sZUxvZygpIHtcbiAgY29uc29sZS5sb2coJ1dJVEhJTiBTT1VSQ0UnKVxufVxuXG5leHBvcnQgZnVuY3Rpb24gdGhyb3dFcnJvcigpIHtcbiAgdGhyb3cgbmV3IEVycm9yKCdXSVRISU4gU09VUkNFJylcbn1cbiJdLCJ2ZXJzaW9uIjozfQ==
===[ INLINE SOURCE MAPS ]=======================================================
mappings: >-
;;;;;;AAAA,SAAgB,UAAhB,GAA0B;AACxB,EAAA,OAAO,CAAC,GAAR,CAAY,eAAZ;AACD;;AAFD,OAAA,CAAA,UAAA,GAAA,UAAA;;AAIA,SAAgB,UAAhB,GAA0B;AACxB,QAAM,IAAI,KAAJ,CAAU,eAAV,CAAN;AACD;;AAFD,OAAA,CAAA,UAAA,GAAA,UAAA
names: []
sourceRoot: <cwd>/
sources:
- main.ts
- <cwd>/main.ts
sourcesContent:
- |
export function consoleLog() {
Expand Down Expand Up @@ -282,15 +279,14 @@ exports[`using template "with-jest-22" should have the source maps comment 1`] =
throw new Error('WITHIN SOURCE');
}
exports.throwError = throwError;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoibWFpbi50cyIsIm1hcHBpbmdzIjoiOztBQUFBLFNBQWdCLFVBQVU7SUFDeEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsQ0FBQTtBQUM5QixDQUFDO0FBRkQsZ0NBRUM7QUFFRCxTQUFnQixVQUFVO0lBQ3hCLE1BQU0sSUFBSSxLQUFLLENBQUMsZUFBZSxDQUFDLENBQUE7QUFDbEMsQ0FBQztBQUZELGdDQUVDIiwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiPGN3ZD4vIiwic291cmNlcyI6WyJtYWluLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBjb25zb2xlTG9nKCkge1xuICBjb25zb2xlLmxvZygnV0lUSElOIFNPVVJDRScpXG59XG5cbmV4cG9ydCBmdW5jdGlvbiB0aHJvd0Vycm9yKCkge1xuICB0aHJvdyBuZXcgRXJyb3IoJ1dJVEhJTiBTT1VSQ0UnKVxufVxuIl0sInZlcnNpb24iOjN9
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiPGN3ZD4vbWFpbi50cyIsIm1hcHBpbmdzIjoiOztBQUFBLFNBQWdCLFVBQVU7SUFDeEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsQ0FBQTtBQUM5QixDQUFDO0FBRkQsZ0NBRUM7QUFFRCxTQUFnQixVQUFVO0lBQ3hCLE1BQU0sSUFBSSxLQUFLLENBQUMsZUFBZSxDQUFDLENBQUE7QUFDbEMsQ0FBQztBQUZELGdDQUVDIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbIjxjd2Q+L21haW4udHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGNvbnNvbGVMb2coKSB7XG4gIGNvbnNvbGUubG9nKCdXSVRISU4gU09VUkNFJylcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHRocm93RXJyb3IoKSB7XG4gIHRocm93IG5ldyBFcnJvcignV0lUSElOIFNPVVJDRScpXG59XG4iXSwidmVyc2lvbiI6M30=
===[ INLINE SOURCE MAPS ]=======================================================
file: main.ts
file: <cwd>/main.ts
mappings: >-
;;AAAA,SAAgB,UAAU;IACxB,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAC9B,CAAC;AAFD,gCAEC;AAED,SAAgB,UAAU;IACxB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;AAClC,CAAC;AAFD,gCAEC
names: []
sourceRoot: <cwd>/
sources:
- main.ts
- <cwd>/main.ts
sourcesContent:
- |
export function consoleLog() {
Expand Down Expand Up @@ -368,15 +364,14 @@ exports[`using template "with-typescript-2-7" should have the source maps commen
throw new Error('WITHIN SOURCE');
}
exports.throwError = throwError;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoibWFpbi50cyIsIm1hcHBpbmdzIjoiOztBQUFBO0lBQ0UsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsQ0FBQTtBQUM5QixDQUFDO0FBRkQsZ0NBRUM7QUFFRDtJQUNFLE1BQU0sSUFBSSxLQUFLLENBQUMsZUFBZSxDQUFDLENBQUE7QUFDbEMsQ0FBQztBQUZELGdDQUVDIiwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiPGN3ZD4vIiwic291cmNlcyI6WyJtYWluLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBjb25zb2xlTG9nKCkge1xuICBjb25zb2xlLmxvZygnV0lUSElOIFNPVVJDRScpXG59XG5cbmV4cG9ydCBmdW5jdGlvbiB0aHJvd0Vycm9yKCkge1xuICB0aHJvdyBuZXcgRXJyb3IoJ1dJVEhJTiBTT1VSQ0UnKVxufVxuIl0sInZlcnNpb24iOjN9
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiPGN3ZD4vbWFpbi50cyIsIm1hcHBpbmdzIjoiOztBQUFBO0lBQ0UsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsQ0FBQTtBQUM5QixDQUFDO0FBRkQsZ0NBRUM7QUFFRDtJQUNFLE1BQU0sSUFBSSxLQUFLLENBQUMsZUFBZSxDQUFDLENBQUE7QUFDbEMsQ0FBQztBQUZELGdDQUVDIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbIjxjd2Q+L21haW4udHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGNvbnNvbGVMb2coKSB7XG4gIGNvbnNvbGUubG9nKCdXSVRISU4gU09VUkNFJylcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHRocm93RXJyb3IoKSB7XG4gIHRocm93IG5ldyBFcnJvcignV0lUSElOIFNPVVJDRScpXG59XG4iXSwidmVyc2lvbiI6M30=
===[ INLINE SOURCE MAPS ]=======================================================
file: main.ts
file: <cwd>/main.ts
mappings: >-
;;AAAA;IACE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAC9B,CAAC;AAFD,gCAEC;AAED;IACE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;AAClC,CAAC;AAFD,gCAEC
names: []
sourceRoot: <cwd>/
sources:
- main.ts
- <cwd>/main.ts
sourcesContent:
- |
export function consoleLog() {
Expand Down
6 changes: 4 additions & 2 deletions e2e/__tests__/source-map.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { join } from 'path'

import { allValidPackageSets } from '../__helpers__/templates'
import { configureTestCase } from '../__helpers__/test-case'

Expand All @@ -20,12 +22,12 @@ testCase.runWithTemplates(allValidPackageSets, 1, (runTest, { templateName }) =>
// and the debugger cannot find the line where to go
it(`should have the source maps comment`, () => {
const io = result.ioFor('main.ts')
const filePath = join(result.cwd, 'main.ts')
expect(io).toMatchSnapshot()
// we could keep only the snapshot testing, but this ensure fixed stuff are the same over versions
expect(io.outputSourceMaps).toMatchObject({
names: [],
sourceRoot: result.cwd,
sources: ['main.ts'],
sources: [filePath],
sourcesContent: [io.inputCode],
version: 3,
})
Expand Down
19 changes: 9 additions & 10 deletions src/compiler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LogLevels } from 'bs-logger'

import * as fakers from './__helpers__/fakers'
import { logTargetMock } from './__helpers__/mocks'
import { relativeToRoot, tempDir } from './__helpers__/path'
import { tempDir } from './__helpers__/path'
import ProcessedSource from './__helpers__/processed-source'
import { createCompiler } from './compiler'
import { ConfigSet } from './config/config-set'
Expand Down Expand Up @@ -60,7 +60,8 @@ describe('source-maps', () => {
const source = 'const f = (v: number) => v\nconst t: number = f(5)'
const compiled = compiler.compile(source, __filename)
const processed = new ProcessedSource(compiled, __filename)
const expectedFileName = relativeToRoot(__filename)
// const expectedFileName = relativeToRoot(__filename)
const expectedFileName = __filename
expect(processed.outputSourceMaps).toMatchObject({
file: expectedFileName,
sources: [expectedFileName],
Expand Down Expand Up @@ -108,14 +109,13 @@ Array [
===[ FILE: src/compiler.spec.ts ]===============================================
"use strict";
console.log("hello");
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoic3JjL2NvbXBpbGVyLnNwZWMudHMiLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLENBQUEiLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiI8Y3dkPi8iLCJzb3VyY2VzIjpbInNyYy9jb21waWxlci5zcGVjLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImNvbnNvbGUubG9nKFwiaGVsbG9cIikiXSwidmVyc2lvbiI6M30=
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiPGN3ZD4vc3JjL2NvbXBpbGVyLnNwZWMudHMiLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLENBQUEiLCJuYW1lcyI6W10sInNvdXJjZXMiOlsiPGN3ZD4vc3JjL2NvbXBpbGVyLnNwZWMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiY29uc29sZS5sb2coXCJoZWxsb1wiKSJdLCJ2ZXJzaW9uIjozfQ==
===[ INLINE SOURCE MAPS ]=======================================================
file: src/compiler.spec.ts
file: <cwd>/src/compiler.spec.ts
mappings: ';AAAA,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA'
names: []
sourceRoot: <cwd>/
sources:
- src/compiler.spec.ts
- <cwd>/src/compiler.spec.ts
sourcesContent:
- console.log("hello")
version: 3
Expand All @@ -138,14 +138,13 @@ describe('isolatedModules', () => {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = 42;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoic3JjL2NvbXBpbGVyLnNwZWMudHMiLCJtYXBwaW5ncyI6Ijs7QUFBQSxrQkFBZSxFQUFFLENBQUEiLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiI8Y3dkPi8iLCJzb3VyY2VzIjpbInNyYy9jb21waWxlci5zcGVjLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IDQyIl0sInZlcnNpb24iOjN9
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiPGN3ZD4vc3JjL2NvbXBpbGVyLnNwZWMudHMiLCJtYXBwaW5ncyI6Ijs7QUFBQSxrQkFBZSxFQUFFLENBQUEiLCJuYW1lcyI6W10sInNvdXJjZXMiOlsiPGN3ZD4vc3JjL2NvbXBpbGVyLnNwZWMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGRlZmF1bHQgNDIiXSwidmVyc2lvbiI6M30=
===[ INLINE SOURCE MAPS ]=======================================================
file: src/compiler.spec.ts
file: <cwd>/src/compiler.spec.ts
mappings: ';;AAAA,kBAAe,EAAE,CAAA'
names: []
sourceRoot: <cwd>/
sources:
- src/compiler.spec.ts
- <cwd>/src/compiler.spec.ts
sourcesContent:
- export default 42
version: 3
Expand Down
13 changes: 8 additions & 5 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,15 @@ function updateOutput(
/**
* Update the source map contents for improved output.
*/
function updateSourceMap(sourceMapText: string, fileName: string, sourceRoot: string) {
function updateSourceMap(sourceMapText: string, fileName: string, _sourceRoot: string) {
const sourceMap = JSON.parse(sourceMapText)
const relativeFilePath = relative(sourceRoot, fileName)
sourceMap.file = relativeFilePath
sourceMap.sources = [relativeFilePath]
sourceMap.sourceRoot = sourceRoot
// const relativeFilePath = posix.normalize(relative(sourceRoot, fileName))
// sourceMap.file = relativeFilePath
// sourceMap.sources = [relativeFilePath]
// sourceMap.sourceRoot = normalize(sourceRoot)
sourceMap.file = fileName
sourceMap.sources = [fileName]
delete sourceMap.sourceRoot
return stableStringify(sourceMap)
}

Expand Down
8 changes: 5 additions & 3 deletions src/config/config-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { LogContexts, Logger } from 'bs-logger'
import { existsSync, readFileSync } from 'fs'
import json5 from 'json5'
import { dirname, isAbsolute, join, resolve } from 'path'
import { dirname, isAbsolute, join, normalize, resolve } from 'path'
import semver from 'semver'
import {
CompilerOptions,
Expand Down Expand Up @@ -461,12 +461,14 @@ export class ConfigSet {
}
}

@Memoize()
get rootDir(): string {
return this.jest.rootDir || this.cwd
return normalize(this.jest.rootDir || this.cwd)
}

@Memoize()
get cwd(): string {
return this.jest.cwd || process.cwd()
return normalize(this.jest.cwd || process.cwd())
}

get isDoctoring() {
Expand Down
7 changes: 4 additions & 3 deletions src/ts-jest-transformer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import stringify from 'fast-json-stable-stringify'
import { sep } from 'path'
import { ParsedCommandLine } from 'typescript'

import { logTargetMock } from './__helpers__/mocks'
import { TsJestTransformer } from './ts-jest-transformer'

describe('configFor', () => {
it('should return the same config-set for same values', () => {
const obj1 = { cwd: '/foo', rootDir: '/bar', globals: {} }
const obj1 = { cwd: '/foo/.', rootDir: '/bar//dummy/..', globals: {} }
const obj2 = { ...obj1 }
const str = stringify(obj1)
const cs1 = new TsJestTransformer().configsFor(obj1 as any)
const cs2 = new TsJestTransformer().configsFor(obj2 as any)
const cs3 = new TsJestTransformer().configsFor(str)
expect(cs1.cwd).toBe('/foo')
expect(cs1.rootDir).toBe('/bar')
expect(cs1.cwd).toBe(`${sep}foo`)
expect(cs1.rootDir).toBe(`${sep}bar`)
expect(cs2).toBe(cs1)
expect(cs3).toBe(cs1)
})
Expand Down

0 comments on commit c12dfff

Please sign in to comment.