2022-05-05 17:34:52 +02:00
|
|
|
import yargs = require('yargs');
|
|
|
|
import { chdir } from 'process';
|
2023-03-19 17:37:07 +02:00
|
|
|
import { rootDir } from './tool-utils';
|
|
|
|
import { execCommand } from '@joplin/utils';
|
2022-05-05 17:34:52 +02:00
|
|
|
|
|
|
|
const main = async () => {
|
|
|
|
const argv = await yargs.argv;
|
|
|
|
const filePaths = argv._ as string[];
|
2024-02-26 12:16:23 +02:00
|
|
|
const processAll = !!argv.all;
|
2022-05-05 17:34:52 +02:00
|
|
|
if (!filePaths || !filePaths.length) return;
|
|
|
|
|
|
|
|
chdir(rootDir);
|
|
|
|
|
2024-02-26 12:16:23 +02:00
|
|
|
let cmd = ['yarn', 'spellcheck-base'];
|
|
|
|
|
|
|
|
if (processAll) {
|
|
|
|
cmd.push('**/*.{ts,tsx}');
|
|
|
|
} else {
|
|
|
|
cmd = cmd.concat(filePaths);
|
|
|
|
}
|
|
|
|
|
2022-05-05 17:34:52 +02:00
|
|
|
try {
|
2024-02-26 12:16:23 +02:00
|
|
|
await execCommand(cmd, { showStderr: false, showStdout: false });
|
2022-05-05 17:34:52 +02:00
|
|
|
} catch (error) {
|
2022-05-06 11:37:39 +02:00
|
|
|
if (!error.stdout.trim()) return;
|
|
|
|
|
2022-05-05 17:34:52 +02:00
|
|
|
console.error(`Some spelling mistakes were found:\n${error.stdout}`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
main().catch((error) => {
|
|
|
|
console.error('Fatal error');
|
|
|
|
console.error(error);
|
|
|
|
process.exit(1);
|
|
|
|
});
|