Skip to content

Commit

Permalink
fixed init flow
Browse files Browse the repository at this point in the history
  • Loading branch information
skymen committed Dec 25, 2023
1 parent 7236707 commit 7829961
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion commands/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async function create(type, params) {
await installDependencies(path);
await maybeExecuteInitScript(path);
updateAddonPlaceholder(path, type, params);
console.log(`${chalk.green.bold("addon created successfully")}`);
}

function validateValues(type, params) {
Expand Down Expand Up @@ -94,6 +95,7 @@ async function cloneTemplate(type, params) {
}

function updateAddonPlaceholder(addonPath, type, params) {
console.log(`${chalk.white.bold("updating addon config ...")}`);
const { addonName, addonAuthor } = params;
const templateFile = addonTemplate[type].config;
const addonConfigPath = path.resolve(
Expand Down Expand Up @@ -136,7 +138,15 @@ function maybeExecuteInitScript(addonPath) {
const initScriptPath = path.resolve(process.cwd(), addonPath, "init.js");
if (fs.existsSync(initScriptPath)) {
console.log(`${chalk.white.bold("executing init script ...")}`);
require(initScriptPath);
const init = require(initScriptPath);
init()
.then(() => {
resolve();
})
.catch((err) => {
console.error(err);
reject(err);
});
} else {
resolve();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "c3ide2-cli",
"description": "A simple CLI for scaffolding construct 3 addons using c3ide2-framework",
"version": "1.2.1",
"version": "1.2.2",
"main": "index.js",
"license": "MIT",
"dependencies": {
Expand Down

0 comments on commit 7829961

Please sign in to comment.