Skip to content

Commit

Permalink
Fix a bug (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-wd authored Dec 10, 2023
1 parent a327717 commit 5e8e22c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
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

0 comments on commit 5e8e22c

Please sign in to comment.