Skip to content

Commit 5e8e22c

Browse files
authored
Fix a bug (#12)
1 parent a327717 commit 5e8e22c

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

commands/setup_theme.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@ async function setup_theme(themeName) {
4141
try {
4242
// Check if theme name is in kebab-case
4343
if (!isKebabCase(themeName)) {
44-
console.error(
45-
chalk.orange('Theme name must be in kebab-case (example-theme-name).')
44+
console.log(
45+
chalk.red('\nTheme name must be in kebab-case (example-theme-name')
4646
);
47-
return;
47+
return false;
4848
}
4949

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

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

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

101101
console.log(
102-
'Theme has been set up. Please activate the theme from the WordPress admin panel.'
102+
chalk.green(
103+
'Theme has been set up. Please activate the theme from the WordPress admin panel.'
104+
)
103105
);
104106

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@webredone/trb-cli",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"description": "TRB-CLI is a handy Node.js CLI that automates the process of managing blocks in a Theme Redone WordPress theme",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)