From d10f342fdb96248262fb31c40969a5bf1a6a4741 Mon Sep 17 00:00:00 2001 From: Igor Chulinda Date: Fri, 4 Nov 2016 17:04:05 +0100 Subject: [PATCH 1/3] Fix for #45 and integration tests --- .gitignore | 3 +++ .npmignore | 3 +++ src/default-retrieve-map-handler.ts | 20 -------------------- src/index.ts | 2 -- src/retrieve-sourceMap-url.ts | 14 -------------- tests/button/__mocks__/ts-jest.ts | 2 -- tests/button/node_modules/ts-jest.js | 1 + tests/simple/__mocks__/ts-jest.ts | 2 -- tests/simple/node_modules/ts-jest.js | 1 + tests/tsconfig-test/__mocks__/ts-jest.ts | 2 -- tests/watch-test/__mocks__/ts-jest.ts | 2 -- tests/watch-test/node_modules/ts-jest.js | 1 + 12 files changed, 9 insertions(+), 44 deletions(-) delete mode 100644 src/default-retrieve-map-handler.ts delete mode 100644 src/retrieve-sourceMap-url.ts delete mode 100644 tests/button/__mocks__/ts-jest.ts create mode 100644 tests/button/node_modules/ts-jest.js delete mode 100644 tests/simple/__mocks__/ts-jest.ts create mode 100644 tests/simple/node_modules/ts-jest.js delete mode 100644 tests/tsconfig-test/__mocks__/ts-jest.ts delete mode 100644 tests/watch-test/__mocks__/ts-jest.ts create mode 100644 tests/watch-test/node_modules/ts-jest.js diff --git a/.gitignore b/.gitignore index 82539a8b8d..b1dc0a4c62 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,6 @@ jspm_packages # Optional REPL history .node_repl_history + +# We need to include this folders, because they are mocks for integration tests +!tests/**/node_modules diff --git a/.npmignore b/.npmignore index 3b6328d017..fd050273ec 100644 --- a/.npmignore +++ b/.npmignore @@ -17,6 +17,9 @@ pids *.pid *.seed +# nodist config for testing in different versions of node +.node-version + # Directory for instrumented libs generated by jscoverage/JSCover lib-cov diff --git a/src/default-retrieve-map-handler.ts b/src/default-retrieve-map-handler.ts deleted file mode 100644 index cb5fcb25ad..0000000000 --- a/src/default-retrieve-map-handler.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { retrieveSourceMapURL } from './retrieve-sourceMap-url'; - -export function defaultRetrieveMapHandler(source) { - var sourceMappingURL = retrieveSourceMapURL(source); - if (!sourceMappingURL) return null; - var startOfSourceMap = sourceMappingURL.indexOf(',') + 1; - /// Check that there is source map - if (startOfSourceMap === 0) return null; - // Reading source map URL as a data url, because it is always inlined - var rawData = sourceMappingURL.slice(startOfSourceMap); - var sourceMapData = new Buffer(rawData, 'base64').toString(); - sourceMappingURL = null; //TODO: why `null` instead of `source` as in original sourceMaphandler? - - if (!sourceMapData) return null; - - return { - url: sourceMappingURL, - map: sourceMapData - }; -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 6333eca34d..1f8bc46ab0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,9 @@ -import { defaultRetrieveMapHandler } from './default-retrieve-map-handler'; import { defaultRetrieveFileHandler } from './default-retrieve-file-handler'; import * as sourceMapSupport from 'source-map-support'; export function install() { var options: sourceMapSupport.Options = {}; options.retrieveFile = defaultRetrieveFileHandler; - options.retrieveSourceMap = defaultRetrieveMapHandler; options.emptyCacheBetweenOperations = true; // left here only for sourceMapCache TODO: check this for correctness and performance with false velue options['environment'] = 'node'; diff --git a/src/retrieve-sourceMap-url.ts b/src/retrieve-sourceMap-url.ts deleted file mode 100644 index 3ac7fed559..0000000000 --- a/src/retrieve-sourceMap-url.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { defaultRetrieveFileHandler } from './default-retrieve-file-handler'; - -export function retrieveSourceMapURL(source) { - // Get the URL of the source map - var fileData = defaultRetrieveFileHandler(source); - // //# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */ - var re = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/)[ \t]*$)/mg; - // Keep executing the search to find the *last* sourceMappingURL to avoid - // picking up sourceMappingURLs from comments, strings, etc. - var lastMatch, match; - while (match = re.exec(fileData)) lastMatch = match; - if (!lastMatch) return null; - return lastMatch[1]; -}; \ No newline at end of file diff --git a/tests/button/__mocks__/ts-jest.ts b/tests/button/__mocks__/ts-jest.ts deleted file mode 100644 index d8807e2a35..0000000000 --- a/tests/button/__mocks__/ts-jest.ts +++ /dev/null @@ -1,2 +0,0 @@ -// we have to mock ts-jest package here, because we don't want create extra node_modules folders -module.exports = require('../../../'); \ No newline at end of file diff --git a/tests/button/node_modules/ts-jest.js b/tests/button/node_modules/ts-jest.js new file mode 100644 index 0000000000..6bb2ded8c1 --- /dev/null +++ b/tests/button/node_modules/ts-jest.js @@ -0,0 +1 @@ +module.exports = require('../../../'); \ No newline at end of file diff --git a/tests/simple/__mocks__/ts-jest.ts b/tests/simple/__mocks__/ts-jest.ts deleted file mode 100644 index d8807e2a35..0000000000 --- a/tests/simple/__mocks__/ts-jest.ts +++ /dev/null @@ -1,2 +0,0 @@ -// we have to mock ts-jest package here, because we don't want create extra node_modules folders -module.exports = require('../../../'); \ No newline at end of file diff --git a/tests/simple/node_modules/ts-jest.js b/tests/simple/node_modules/ts-jest.js new file mode 100644 index 0000000000..6bb2ded8c1 --- /dev/null +++ b/tests/simple/node_modules/ts-jest.js @@ -0,0 +1 @@ +module.exports = require('../../../'); \ No newline at end of file diff --git a/tests/tsconfig-test/__mocks__/ts-jest.ts b/tests/tsconfig-test/__mocks__/ts-jest.ts deleted file mode 100644 index d8807e2a35..0000000000 --- a/tests/tsconfig-test/__mocks__/ts-jest.ts +++ /dev/null @@ -1,2 +0,0 @@ -// we have to mock ts-jest package here, because we don't want create extra node_modules folders -module.exports = require('../../../'); \ No newline at end of file diff --git a/tests/watch-test/__mocks__/ts-jest.ts b/tests/watch-test/__mocks__/ts-jest.ts deleted file mode 100644 index d8807e2a35..0000000000 --- a/tests/watch-test/__mocks__/ts-jest.ts +++ /dev/null @@ -1,2 +0,0 @@ -// we have to mock ts-jest package here, because we don't want create extra node_modules folders -module.exports = require('../../../'); \ No newline at end of file diff --git a/tests/watch-test/node_modules/ts-jest.js b/tests/watch-test/node_modules/ts-jest.js new file mode 100644 index 0000000000..6bb2ded8c1 --- /dev/null +++ b/tests/watch-test/node_modules/ts-jest.js @@ -0,0 +1 @@ +module.exports = require('../../../'); \ No newline at end of file From 77b44c851b635a783728da60d47334fd55ff4cf2 Mon Sep 17 00:00:00 2001 From: Igor Chulinda Date: Fri, 4 Nov 2016 17:06:30 +0100 Subject: [PATCH 2/3] Small refactor. --- src/transpile-if-ts.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/transpile-if-ts.ts b/src/transpile-if-ts.ts index 281c97d846..2c9c596ef0 100644 --- a/src/transpile-if-ts.ts +++ b/src/transpile-if-ts.ts @@ -5,17 +5,11 @@ export function transpileIfTypescript(path, contents) { if (path && (path.endsWith('.tsx') || path.endsWith('.ts'))) { let transpiled = tsc.transpileModule(contents, { - compilerOptions: addSourceMapToTSConfig(), + compilerOptions: getTSConfig({ __TS_CONFIG__: global['__TS_CONFIG__'] }, true), fileName: path }); return transpiled.outputText; } return contents; -} - -function addSourceMapToTSConfig() { - // if a global __TS_CONFIG__ is set, update the compiler setting to include inline SourceMap - var config = getTSConfig({ __TS_CONFIG__: global['__TS_CONFIG__'] }, true); - return config; } \ No newline at end of file From e1f95e524ed62091736f70abf63530f1f107ec03 Mon Sep 17 00:00:00 2001 From: Igor Chulinda Date: Fri, 4 Nov 2016 17:20:15 +0100 Subject: [PATCH 3/3] Adding appveyor CI --- README.md | 1 + appveyor.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 appveyor.yml diff --git a/README.md b/README.md index 8bfc9a2798..a84bb29beb 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Build Status for node v7](https://travis-badges.herokuapp.com/repos/kulshekhar/ts-jest/branches/master?job=0)](https://travis-ci.org/kulshekhar/ts-jest) [![Build Status for node v6](https://travis-badges.herokuapp.com/repos/kulshekhar/ts-jest/branches/master?job=1)](https://travis-ci.org/kulshekhar/ts-jest) [![Build Status for node v4](https://travis-badges.herokuapp.com/repos/kulshekhar/ts-jest/branches/master?job=2)](https://travis-ci.org/kulshekhar/ts-jest) +[![Build Status for Windows](https://ci.appveyor.com/api/projects/status/gknb1pl72o0w0coc?svg=true)](https://ci.appveyor.com/project/Igmat/ts-jest) ## Table of Contents diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000..3bf2764e53 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,28 @@ +# appveyor file +# http://www.appveyor.com/docs/appveyor-yml + +# build version format +version: "{build}" + +# fix lineendings in Windows +init: + - git config --global core.autocrlf input + +# what combinations to test +environment: + matrix: + - nodejs_version: 4 + - nodejs_version: 6 + - nodejs_version: 7 + +# get the latest stable version of Node 0.STABLE.latest +install: + - ps: Install-Product node $env:nodejs_version + - npm install + +build: off + +test_script: + - node --version + - npm --version + - cmd: npm test --no-color \ No newline at end of file