From eb8e78f741142be055bad8ad92507eca3dcc57e2 Mon Sep 17 00:00:00 2001 From: biodiscus Date: Mon, 23 Dec 2024 17:50:55 +0100 Subject: [PATCH] chore: switch from del-cli back to rimraf, because del does not work on win --- package.json | 2 +- test/ts/default-import-as/package.json | 6 ++-- test/ts/default-import/package.json | 6 ++-- test/ts/extend-colors/package.json | 6 ++-- test/ts/mix-import/package.json | 6 ++-- test/ts/named-import-color-func/package.json | 6 ++-- test/ts/named-import-simple/package.json | 6 ++-- test/utils/helpers.js | 33 +++++++++++--------- 8 files changed, 37 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index ed2881a..c95aefe 100644 --- a/package.json +++ b/package.json @@ -92,9 +92,9 @@ "@types/node": "^22.10.2", "@vitest/coverage-v8": "^2.1.8", "ansis": "file:dist", - "del-cli": "^6.0.0", "esbuild": "^0.24.2", "prettier": "^3.4.2", + "rimraf": "^6.0.1", "rollup": "^4.29.1", "rollup-plugin-copy": "^3.5.0", "swc": "^1.0.11", diff --git a/test/ts/default-import-as/package.json b/test/ts/default-import-as/package.json index b1fe954..9fd6821 100644 --- a/test/ts/default-import-as/package.json +++ b/test/ts/default-import-as/package.json @@ -1,8 +1,8 @@ { "scripts": { - "build": "del dist/* && tsc && node dist/index.js --color=true > dist/index.out", - "build:swc": "del dist/* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", - "build:esbuild": "del dist/* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", + "build": "rimraf --glob dist/*.* && tsc && node dist/index.js --color=true > dist/index.out", + "build:swc": "rimraf --glob dist/*.* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", + "build:esbuild": "rimraf --glob dist/*.* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", "view": "node ./dist/index.js" } } \ No newline at end of file diff --git a/test/ts/default-import/package.json b/test/ts/default-import/package.json index b1fe954..9fd6821 100644 --- a/test/ts/default-import/package.json +++ b/test/ts/default-import/package.json @@ -1,8 +1,8 @@ { "scripts": { - "build": "del dist/* && tsc && node dist/index.js --color=true > dist/index.out", - "build:swc": "del dist/* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", - "build:esbuild": "del dist/* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", + "build": "rimraf --glob dist/*.* && tsc && node dist/index.js --color=true > dist/index.out", + "build:swc": "rimraf --glob dist/*.* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", + "build:esbuild": "rimraf --glob dist/*.* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", "view": "node ./dist/index.js" } } \ No newline at end of file diff --git a/test/ts/extend-colors/package.json b/test/ts/extend-colors/package.json index b1fe954..9fd6821 100644 --- a/test/ts/extend-colors/package.json +++ b/test/ts/extend-colors/package.json @@ -1,8 +1,8 @@ { "scripts": { - "build": "del dist/* && tsc && node dist/index.js --color=true > dist/index.out", - "build:swc": "del dist/* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", - "build:esbuild": "del dist/* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", + "build": "rimraf --glob dist/*.* && tsc && node dist/index.js --color=true > dist/index.out", + "build:swc": "rimraf --glob dist/*.* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", + "build:esbuild": "rimraf --glob dist/*.* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", "view": "node ./dist/index.js" } } \ No newline at end of file diff --git a/test/ts/mix-import/package.json b/test/ts/mix-import/package.json index b1fe954..9fd6821 100644 --- a/test/ts/mix-import/package.json +++ b/test/ts/mix-import/package.json @@ -1,8 +1,8 @@ { "scripts": { - "build": "del dist/* && tsc && node dist/index.js --color=true > dist/index.out", - "build:swc": "del dist/* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", - "build:esbuild": "del dist/* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", + "build": "rimraf --glob dist/*.* && tsc && node dist/index.js --color=true > dist/index.out", + "build:swc": "rimraf --glob dist/*.* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", + "build:esbuild": "rimraf --glob dist/*.* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", "view": "node ./dist/index.js" } } \ No newline at end of file diff --git a/test/ts/named-import-color-func/package.json b/test/ts/named-import-color-func/package.json index b1fe954..9fd6821 100644 --- a/test/ts/named-import-color-func/package.json +++ b/test/ts/named-import-color-func/package.json @@ -1,8 +1,8 @@ { "scripts": { - "build": "del dist/* && tsc && node dist/index.js --color=true > dist/index.out", - "build:swc": "del dist/* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", - "build:esbuild": "del dist/* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", + "build": "rimraf --glob dist/*.* && tsc && node dist/index.js --color=true > dist/index.out", + "build:swc": "rimraf --glob dist/*.* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", + "build:esbuild": "rimraf --glob dist/*.* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", "view": "node ./dist/index.js" } } \ No newline at end of file diff --git a/test/ts/named-import-simple/package.json b/test/ts/named-import-simple/package.json index b1fe954..9fd6821 100644 --- a/test/ts/named-import-simple/package.json +++ b/test/ts/named-import-simple/package.json @@ -1,8 +1,8 @@ { "scripts": { - "build": "del dist/* && tsc && node dist/index.js --color=true > dist/index.out", - "build:swc": "del dist/* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", - "build:esbuild": "del dist/* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", + "build": "rimraf --glob dist/*.* && tsc && node dist/index.js --color=true > dist/index.out", + "build:swc": "rimraf --glob dist/*.* && swc ./src -d dist && node dist/index.js --color=true > dist/index.out", + "build:esbuild": "rimraf --glob dist/*.* && esbuild src/index.ts --bundle --outfile=dist/index.js && node dist/index.js --color=true > dist/index.out", "view": "node ./dist/index.js" } } \ No newline at end of file diff --git a/test/utils/helpers.js b/test/utils/helpers.js index c7d77a1..4761e2c 100644 --- a/test/utils/helpers.js +++ b/test/utils/helpers.js @@ -34,7 +34,10 @@ export const readTextFileSync = (file) => { if (!fs.existsSync(file)) { throw new Error(`\nERROR: the file "${file}" not found.`); } - return fs.readFileSync(file, 'utf-8'); + let content = fs.readFileSync(file, 'utf-8'); + + // ensue that the correct line endings are used across different operating systems + return isWin ? content.replace(/\r\n/g, '\n') : content; }; /** @@ -128,20 +131,20 @@ export const executeTSFile = (testPath, compiler = 'tsc') => { this.result = { received, expected }; expect(received).toEqual(expected); - }) - // debugging inner errors - .catch((error) => { - let message; - //console.log('>> err: ', error); - if (typeof error === 'string') { - message = '\n' + error; - } else if('stdout' in error && 'stderr' in error) { - message = error.stdout + '\n' + error.stderr; - } else { - message = '\n' + error.toString(); - } - - expect.fail(testPath + message); }); + // debugging inner errors + // .catch((error) => { + // let message; + // //console.log('>> err: ', error); + // if (typeof error === 'string') { + // message = '\n' + error; + // } else if('stdout' in error && 'stderr' in error) { + // message = error.stdout + '\n' + error.stderr; + // } else { + // message = '\n' + error.toString(); + // } + // + // expect.fail(testPath + message); + // }); }; \ No newline at end of file