The Vue ESLint plugin is not compatible with Vite and isn't provided in Vite's default template. By removing it, the codebase progresses toward the migration to Vue 3.0 and Vite (#230). Changes: - Directly execute `eslint` in the `npm run lint:eslint` command. - Fix previously undetected linting issues that weren't covered by Vue CLI's default configuration. - Updated various configuration files, reflecting the removal and lint fixes. - Remove unused `eslint-plugin-import` dependency that is already imported by `@vue/eslint-config-airbnb-with-typescript`. In `.eslintrc.cjs`: - Add `es2022` as environment in to simplify setting parser options and align with Vite starter configuration. - Remove useless tests override. - Move tests override in root `.eslintrc.cjs` to `tests/` for clarity, better organization, scalability and separation of concerns.
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
import { exec } from 'child_process';
|
|
import { indentText } from './text.js';
|
|
|
|
const TIMEOUT_IN_SECONDS = 180;
|
|
const MAX_OUTPUT_BUFFER_SIZE = 1024 * 1024; // 1 MB
|
|
|
|
export function runCommand(commandString, options) {
|
|
return new Promise((resolve) => {
|
|
options = {
|
|
cwd: process.cwd(),
|
|
timeout: TIMEOUT_IN_SECONDS * 1000,
|
|
maxBuffer: MAX_OUTPUT_BUFFER_SIZE * 2,
|
|
...options,
|
|
};
|
|
|
|
exec(commandString, options, (error, stdout, stderr) => {
|
|
let errorText;
|
|
if (error || stderr?.length > 0) {
|
|
errorText = formatError(commandString, error, stdout, stderr);
|
|
}
|
|
resolve({
|
|
stdout,
|
|
error: errorText,
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
function formatError(commandString, error, stdout, stderr) {
|
|
const errorParts = [
|
|
'Error while running command.',
|
|
`Command:\n${indentText(commandString, 1)}`,
|
|
];
|
|
if (error?.toString().trim()) {
|
|
errorParts.push(`Error:\n${indentText(error.toString(), 1)}`);
|
|
}
|
|
if (stderr?.toString().trim()) {
|
|
errorParts.push(`stderr:\n${indentText(stderr, 1)}`);
|
|
}
|
|
if (stdout?.toString().trim()) {
|
|
errorParts.push(`stdout:\n${indentText(stdout, 1)}`);
|
|
}
|
|
return errorParts.join('\n---\n');
|
|
}
|