diff --git a/package.json b/package.json index b9700485..31c248b1 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "@commitlint/config-conventional": "^8.3.4", "@mdx-js/mdx": "^1.5.8", "@types/babel__code-frame": "^7.0.1", + "@types/cross-spawn": "^6.0.2", "@types/eslint": "^6.8.0", "@types/fs-extra": "^8.1.0", "@types/jest": "^25.2.1", @@ -85,6 +86,7 @@ "@typescript-eslint/eslint-plugin": "^2.27.0", "@typescript-eslint/parser": "^2.27.0", "commitlint": "^8.3.5", + "cross-spawn": "^7.0.2", "eslint": "^6.8.0", "eslint-config-prettier": "^6.10.1", "eslint-plugin-node": "^11.1.0", @@ -101,6 +103,7 @@ "ts-jest": "^25.3.1", "ts-loader": "^6.2.2", "typescript": "^3.8.3", + "unixify": "^1.0.0", "vue": "^2.6.11", "vue-class-component": "^7.2.3", "vue-loader": "^15.9.1", diff --git a/test/e2e/EsLint.spec.ts b/test/e2e/EsLint.spec.ts index ccd136ad..f1ae39b0 100644 --- a/test/e2e/EsLint.spec.ts +++ b/test/e2e/EsLint.spec.ts @@ -30,18 +30,20 @@ describe('EsLint', () => { ])('reports lint error for %p', async ({ async, webpack }) => { await sandbox.load( await readFixture(join(__dirname, 'fixtures/eslint-basic.fixture'), { - FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION, - TS_LOADER_VERSION: '^5.0.0', - TYPESCRIPT_VERSION: '~3.8.0', - WEBPACK_VERSION: webpack, - WEBPACK_CLI_VERSION, - WEBPACK_DEV_SERVER_VERSION, - ASYNC: async ? 'true' : 'false', + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify( + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION + ), + TS_LOADER_VERSION: JSON.stringify('^5.0.0'), + TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'), + WEBPACK_VERSION: JSON.stringify(webpack), + WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION), + WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION), + ASYNC: JSON.stringify(async), }) ); const driver = createWebpackDevServerDriver( - sandbox.spawn('yarn exec webpack-dev-server'), + sandbox.spawn('./node_modules/.bin/webpack-dev-server'), async ); let errors: string[]; diff --git a/test/e2e/PluginOutOfMemory.spec.ts b/test/e2e/PluginOutOfMemory.spec.ts index 21bb6b5a..c176942d 100644 --- a/test/e2e/PluginOutOfMemory.spec.ts +++ b/test/e2e/PluginOutOfMemory.spec.ts @@ -26,13 +26,15 @@ describe('ForkTsCheckerWebpackPlugin Out Of Memory', () => { ])('handles out of memory for %p', async ({ async, webpack }) => { await sandbox.load( await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), { - FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION, - TS_LOADER_VERSION: '^5.0.0', - TYPESCRIPT_VERSION: '~3.8.0', - WEBPACK_VERSION: webpack, - WEBPACK_CLI_VERSION: '^3.3.11', - WEBPACK_DEV_SERVER_VERSION: '^3.10.3', - ASYNC: async ? 'true' : 'false', + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify( + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION + ), + TS_LOADER_VERSION: JSON.stringify('^5.0.0'), + TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'), + WEBPACK_VERSION: JSON.stringify(webpack), + WEBPACK_CLI_VERSION: JSON.stringify('^3.3.11'), + WEBPACK_DEV_SERVER_VERSION: JSON.stringify('^3.10.3'), + ASYNC: JSON.stringify(async), }) ); @@ -48,7 +50,9 @@ describe('ForkTsCheckerWebpackPlugin Out Of Memory', () => { ].join('\n') ); - const driver = createGenericProcessDriver(sandbox.spawn('yarn exec webpack-dev-server')); + const driver = createGenericProcessDriver( + sandbox.spawn('./node_modules/.bin/webpack-dev-server') + ); // we should see an error message about out of memory await driver.waitForStderrIncludes( diff --git a/test/e2e/TypeScriptSolutionBuilderApi.spec.ts b/test/e2e/TypeScriptSolutionBuilderApi.spec.ts index 8e5e1e56..45e18d6c 100644 --- a/test/e2e/TypeScriptSolutionBuilderApi.spec.ts +++ b/test/e2e/TypeScriptSolutionBuilderApi.spec.ts @@ -28,18 +28,20 @@ describe('TypeScript SolutionBuilder API', () => { async ({ async }) => { await sandbox.load( await readFixture(join(__dirname, 'fixtures/typescript-project-references.fixture'), { - FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION, - TS_LOADER_VERSION: '^7.0.1', - TYPESCRIPT_VERSION: '~3.8.0', - WEBPACK_VERSION: '^4.0.0', - WEBPACK_CLI_VERSION, - WEBPACK_DEV_SERVER_VERSION, - ASYNC: async ? 'true' : 'false', + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify( + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION + ), + TS_LOADER_VERSION: JSON.stringify('^7.0.1'), + TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'), + WEBPACK_VERSION: JSON.stringify('^4.0.0'), + WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION), + WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION), + ASYNC: JSON.stringify(async), }) ); const driver = createWebpackDevServerDriver( - sandbox.spawn('yarn exec webpack-dev-server'), + sandbox.spawn('./node_modules/.bin/webpack-dev-server'), async ); let errors: string[]; diff --git a/test/e2e/TypeScriptWatchApi.spec.ts b/test/e2e/TypeScriptWatchApi.spec.ts index 5ccfebda..1a0fdd0c 100644 --- a/test/e2e/TypeScriptWatchApi.spec.ts +++ b/test/e2e/TypeScriptWatchApi.spec.ts @@ -33,13 +33,15 @@ describe('TypeScript Watch API', () => { async ({ async, webpack }) => { await sandbox.load( await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), { - FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION, - TS_LOADER_VERSION: '^5.0.0', - TYPESCRIPT_VERSION: '~3.8.0', - WEBPACK_VERSION: webpack, - WEBPACK_CLI_VERSION, - WEBPACK_DEV_SERVER_VERSION, - ASYNC: async ? 'true' : 'false', + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify( + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION + ), + TS_LOADER_VERSION: JSON.stringify('^5.0.0'), + TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'), + WEBPACK_VERSION: JSON.stringify(webpack), + WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION), + WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION), + ASYNC: JSON.stringify(async), }) ); @@ -52,7 +54,7 @@ describe('TypeScript Watch API', () => { ); const driver = createWebpackDevServerDriver( - sandbox.spawn('yarn exec webpack-dev-server'), + sandbox.spawn('./node_modules/.bin/webpack-dev-server'), async ); let errors: string[]; @@ -155,18 +157,20 @@ describe('TypeScript Watch API', () => { ])('reports semantic error for %p', async ({ async, webpack, typescript, tsloader }) => { await sandbox.load( await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), { - FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION, - TS_LOADER_VERSION: tsloader, - TYPESCRIPT_VERSION: typescript, - WEBPACK_VERSION: webpack, - WEBPACK_CLI_VERSION, - WEBPACK_DEV_SERVER_VERSION, - ASYNC: async ? 'true' : 'false', + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify( + FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION + ), + TS_LOADER_VERSION: JSON.stringify(tsloader), + TYPESCRIPT_VERSION: JSON.stringify(typescript), + WEBPACK_VERSION: JSON.stringify(webpack), + WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION), + WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION), + ASYNC: JSON.stringify(async), }) ); const driver = createWebpackDevServerDriver( - sandbox.spawn('yarn exec webpack-dev-server'), + sandbox.spawn('./node_modules/.bin/webpack-dev-server'), async ); let errors: string[]; diff --git a/test/e2e/fixtures/eslint-basic.fixture b/test/e2e/fixtures/eslint-basic.fixture index 366cae2f..137ac822 100644 --- a/test/e2e/fixtures/eslint-basic.fixture +++ b/test/e2e/fixtures/eslint-basic.fixture @@ -9,12 +9,12 @@ "@typescript-eslint/eslint-plugin": "^2.27.0", "@typescript-eslint/parser": "^2.27.0", "eslint": "^6.8.0", - "fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}", - "ts-loader": "${TS_LOADER_VERSION}", - "typescript": "${TYPESCRIPT_VERSION}", - "webpack": "${WEBPACK_VERSION}", - "webpack-cli": "${WEBPACK_CLI_VERSION}", - "webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}" + "fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}, + "ts-loader": ${TS_LOADER_VERSION}, + "typescript": ${TYPESCRIPT_VERSION}, + "webpack": ${WEBPACK_VERSION}, + "webpack-cli": ${WEBPACK_CLI_VERSION}, + "webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION} } } /// tsconfig.json diff --git a/test/e2e/fixtures/typescript-basic.fixture b/test/e2e/fixtures/typescript-basic.fixture index d1f79dc6..fd89fcc3 100644 --- a/test/e2e/fixtures/typescript-basic.fixture +++ b/test/e2e/fixtures/typescript-basic.fixture @@ -5,12 +5,12 @@ "main": "dist/index.js", "license": "MIT", "devDependencies": { - "fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}", - "ts-loader": "${TS_LOADER_VERSION}", - "typescript": "${TYPESCRIPT_VERSION}", - "webpack": "${WEBPACK_VERSION}", - "webpack-cli": "${WEBPACK_CLI_VERSION}", - "webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}" + "fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}, + "ts-loader": ${TS_LOADER_VERSION}, + "typescript": ${TYPESCRIPT_VERSION}, + "webpack": ${WEBPACK_VERSION}, + "webpack-cli": ${WEBPACK_CLI_VERSION}, + "webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION} } } /// tsconfig.json diff --git a/test/e2e/fixtures/typescript-project-references.fixture b/test/e2e/fixtures/typescript-project-references.fixture index 3837b273..1fbc1f97 100644 --- a/test/e2e/fixtures/typescript-project-references.fixture +++ b/test/e2e/fixtures/typescript-project-references.fixture @@ -8,12 +8,12 @@ "packages/*" ], "devDependencies": { - "fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}", - "ts-loader": "${TS_LOADER_VERSION}", - "typescript": "${TYPESCRIPT_VERSION}", - "webpack": "${WEBPACK_VERSION}", - "webpack-cli": "${WEBPACK_CLI_VERSION}", - "webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}" + "fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}, + "ts-loader": ${TS_LOADER_VERSION}, + "typescript": ${TYPESCRIPT_VERSION}, + "webpack": ${WEBPACK_VERSION}, + "webpack-cli": ${WEBPACK_CLI_VERSION}, + "webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION} } } diff --git a/test/e2e/sandbox/Sandbox.ts b/test/e2e/sandbox/Sandbox.ts index d0d299fc..9e252525 100644 --- a/test/e2e/sandbox/Sandbox.ts +++ b/test/e2e/sandbox/Sandbox.ts @@ -2,7 +2,8 @@ import { join, resolve, dirname } from 'path'; import fs from 'fs-extra'; import os from 'os'; import chalk from 'chalk'; -import { exec, spawn, ChildProcess } from 'child_process'; +import { exec, ChildProcess } from 'child_process'; +import spawn from 'cross-spawn'; import { Fixture } from './Fixture'; import stripAnsi from 'strip-ansi'; diff --git a/test/unit/formatter/WebpackFormatter.spec.ts b/test/unit/formatter/WebpackFormatter.spec.ts index cba6998a..20718426 100644 --- a/test/unit/formatter/WebpackFormatter.spec.ts +++ b/test/unit/formatter/WebpackFormatter.spec.ts @@ -1,5 +1,5 @@ import os from 'os'; -import { join } from 'path'; +import { join, sep } from 'path'; import { Issue } from 'lib/issue'; import { createBasicFormatter, createWebpackFormatter, Formatter } from 'lib/formatter'; @@ -38,7 +38,7 @@ describe('formatter/WebpackFormatter', () => { }); it('formats issue file', () => { - expect(formatter(issue)).toContain('some/file.ts'); + expect(formatter(issue)).toContain(`some${sep}file.ts`); }); it('formats location', () => { @@ -53,7 +53,7 @@ describe('formatter/WebpackFormatter', () => { it('formats issue header like webpack', () => { expect(formatter(issue)).toEqual( - ['ERROR in some/file.ts 1:7-16', 'TS123: Some issue content', ''].join(os.EOL) + [`ERROR in some${sep}file.ts 1:7-16`, 'TS123: Some issue content', ''].join(os.EOL) ); }); }); diff --git a/test/unit/typescript-reporter/TypeScriptReporterConfiguration.spec.ts b/test/unit/typescript-reporter/TypeScriptReporterConfiguration.spec.ts index 0d595d76..ebe14518 100644 --- a/test/unit/typescript-reporter/TypeScriptReporterConfiguration.spec.ts +++ b/test/unit/typescript-reporter/TypeScriptReporterConfiguration.spec.ts @@ -1,4 +1,5 @@ import webpack from 'webpack'; +import unixify from 'unixify'; import { TypeScriptReporterConfiguration } from 'lib/typescript-reporter/TypeScriptReporterConfiguration'; import { TypeScriptReporterOptions } from 'lib/typescript-reporter/TypeScriptReporterOptions'; @@ -87,7 +88,9 @@ describe('typescript-reporter/TypeScriptsReporterConfiguration', () => { options as TypeScriptReporterOptions ); - expect(configuration).toEqual(expectedConfiguration); + expect({ ...configuration, tsconfig: unixify(configuration.tsconfig) }).toEqual( + expectedConfiguration + ); }); it('passes vue options to the vue extension', async () => { diff --git a/yarn.lock b/yarn.lock index b1155a9b..9c8e32ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -884,6 +884,13 @@ resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== +"@types/cross-spawn@^6.0.2": + version "6.0.2" + resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.2.tgz#168309de311cd30a2b8ae720de6475c2fbf33ac7" + integrity sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw== + dependencies: + "@types/node" "*" + "@types/eslint-visitor-keys@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" @@ -2369,7 +2376,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0: +cross-spawn@^7.0.0, cross-spawn@^7.0.2: version "7.0.2" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.2.tgz#d0d7dcfa74e89115c7619f4f721a94e1fdb716d6" integrity sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw== @@ -7188,6 +7195,13 @@ universalify@^1.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d" integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug== +unixify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unixify/-/unixify-1.0.0.tgz#3a641c8c2ffbce4da683a5c70f03a462940c2090" + integrity sha1-OmQcjC/7zk2mg6XHDwOkYpQMIJA= + dependencies: + normalize-path "^2.1.1" + unset-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"