Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug #12

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions commands/setup_theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ async function setup_theme(themeName) {
try {
// Check if theme name is in kebab-case
if (!isKebabCase(themeName)) {
console.error(
chalk.orange('Theme name must be in kebab-case (example-theme-name).')
console.log(
chalk.red('\nTheme name must be in kebab-case (example-theme-name')
);
return;
return false;
}

// Ensure the current working directory ends with wp-themes
const cwd = process.cwd();
if (!cwd.endsWith('wp-themes')) {
console.error(
chalk.orange('This command needs to be run inside a wp-themes folder.')
console.log(
chalk.red('\nThis command needs to be run inside a wp-themes folder.')
);
return;
return false;
}

// Check if theme directory already exists
const newThemePath = path.join('.', themeName);
if (fs.existsSync(newThemePath)) {
console.error(chalk.orange('A theme with this name already exists.'));
return;
console.log(chalk.red('\nTA theme with this name already exists.'));
return false;
}

// Fetch the latest release URL from GitHub API
Expand Down Expand Up @@ -99,7 +99,9 @@ async function setup_theme(themeName) {
fs.unlinkSync('theme-redone.zip');

console.log(
'Theme has been set up. Please activate the theme from the WordPress admin panel.'
chalk.green(
'Theme has been set up. Please activate the theme from the WordPress admin panel.'
)
);

// Read package.json and extract Node version
Expand All @@ -114,7 +116,8 @@ async function setup_theme(themeName) {
'Then, run "npm i" and "composer i" from the theme root directory.'
);
} catch (error) {
console.error(chalk.orange(`Error setting up theme: ${error.message}`));
console.error(chalk.red(`Error setting up theme: ${error.message}`));
return false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webredone/trb-cli",
"version": "3.0.2",
"version": "3.0.3",
"description": "TRB-CLI is a handy Node.js CLI that automates the process of managing blocks in a Theme Redone WordPress theme",
"main": "index.js",
"type": "module",
Expand Down
Loading