diff --git a/.gitignore b/.gitignore index 82cd65c..58f1256 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,6 @@ temp # npm pack result *.tgz -!tarballs/krutoo-ts-loader-0.0.0.tgz # vscode .vscode/settings.json \ No newline at end of file diff --git a/docs/package-lock.json b/docs/package-lock.json index 7431639..074c0b0 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -2385,9 +2385,9 @@ "license": "MIT" }, "node_modules/follow-redirects": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", - "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", "dev": true, "funding": [ { diff --git a/scripts/build.ts b/scripts/build.ts index b4c9464..7b22477 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -2,16 +2,16 @@ * This script will build package. */ import fs from 'node:fs/promises'; -import { execAsync } from './utils.ts'; +import { $ } from './utils.ts'; // clean dist folder await fs.rm('./dist', { recursive: true, force: true }); // build .js files -await execAsync('npx tsc -p tsconfig.build-js.json'); +await $('npx tsc -p tsconfig.build-js.json'); // build .d.ts files -await execAsync('npx tsc -p tsconfig.build-dts.json'); +await $('npx tsc -p tsconfig.build-dts.json'); // format (for reduce package size by replacing indent from 4 to 2) -await execAsync('npx prettier "dist/**/*.js" -w --log-level=error --ignore-path=./.nonexistent'); +await $('npx prettier "dist/**/*.js" -w --log-level=error --ignore-path=./.nonexistent'); diff --git a/scripts/utils.ts b/scripts/utils.ts index 064222c..6629c86 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,4 +1,4 @@ -import { exec } from 'node:child_process'; +import { spawn } from 'node:child_process'; import fs from 'node:fs/promises'; import { EOL } from 'node:os'; import path from 'node:path'; @@ -11,12 +11,30 @@ export function normalizePathname(pathname: string): string { return `./${pathname}`; } -export async function execAsync(cmd: string): Promise { - return await new Promise((done, fail) => { - const proc = exec(cmd, err => (err ? fail(err) : done())); +/** + * Runs shell script using `spawn`. + * @param cmd Command to run. + * @returns Promise that resolves when process closed. + */ +export function $(cmd: string): Promise { + return new Promise((done, fail) => { + const child = spawn(cmd, { + stdio: 'inherit', + shell: true, + env: { ...process.env, FORCE_COLOR: '3' }, + }); - proc.stdout?.pipe(process.stdout); - proc.stderr?.pipe(process.stderr); + child.on('error', fail); + + child.on('close', (code, signal) => { + if (code === 0) { + done(); + } else { + fail( + new Error(signal ? `Process killed, signal ${signal}` : `Process exited, code ${code}`), + ); + } + }); }); } diff --git a/src/mod.ts b/src/mod.ts index e9d08d3..2c729fb 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -2,6 +2,7 @@ // IMPORTANT: "./rspack/mod.ts" is not added here by the same reason // IMPORTANT: "./testing/mod.ts" is not added here because in practice it need only in test environment // IMPORTANT: "./store/mod.ts" is not added here because it is a little bit more than just utility +// IMPORTANT: "./router/mod.ts" is not added here by the same reason export * from './dom/mod.ts'; export * from './math/mod.ts'; export * from './types/mod.ts'; diff --git a/tests-e2e/package-lock.json b/tests-e2e/package-lock.json index 455b964..aa6ac89 100644 --- a/tests-e2e/package-lock.json +++ b/tests-e2e/package-lock.json @@ -2431,9 +2431,9 @@ "license": "MIT" }, "node_modules/follow-redirects": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", - "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", "dev": true, "funding": [ {