29 lines
770 B
JavaScript
29 lines
770 B
JavaScript
const { exec } = require("node:child_process")
|
|
|
|
class GetCategoryUseCase {
|
|
execute(domain) {
|
|
return new Promise((resolve, reject) => {
|
|
exec(`echo ${domain} | bin/gcf1check.sh etc check_categorize_hybrid`, { cwd: '/usr/local/gcf1' }, (error, stdout, stderr) => {
|
|
if (error) {
|
|
console.error(error);
|
|
reject(error);
|
|
return;
|
|
}
|
|
|
|
const outputParts = stdout.split(/\s+/);
|
|
if (outputParts[3]) {
|
|
const categoryId = outputParts[2];
|
|
console.log({ categoryId });
|
|
resolve(categoryId);
|
|
} else {
|
|
console.log({ error: 'Category ID not found' });
|
|
reject('Category ID not found');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = { GetCategoryUseCase }
|
|
|