Skip to content
Merged
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
101 changes: 49 additions & 52 deletions creator/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,65 @@ const readline = require('readline');
const staticConf = require("./configs/staticConf.js");
const server = require("./server/server.js");

const existindex = fs.existsSync("index.html");

// Clean Screen
// Rest of code

const blank = '\n'.repeat(process.stdout.rows);
async function config() {
const answers = await inquirer
.prompt([
{
type: "text",
name: "name",
message: "What is the name of the project ?",
default: path.basename(process.cwd()),
},
{
type: "list",
name: "type",
message: "Do you want to integrate node.js with the p5.js app ?",
choices: [
"static",
"node"
]
}
]);

console.log(blank);
switch (answers.type) {
case "static":
await staticConf(config, answers.name, process.cwd());
break;
}
}

readline.cursorTo(process.stdout, 0, 0);
readline.clearScreenDown(process.stdout);
async function main() {
const existindex = fs.existsSync("index.html");

// Rest of code
// Clean Screen
readline.cursorTo(process.stdout, 0, 0);
readline.clearScreenDown(process.stdout);

function config() {
inquirer
.prompt([
{
type: "text",
name: "name",
message: "What is the name of the project ?",
default: path.basename(process.cwd()),
},
{
type: "list",
name: "type",
message: "Do you want to integrate node.js with the p5.js app ?",
choices: [
"static",
"node"
]
}
])
.then(answers => {
config.name = answers.name;
if (!existindex) {
// simply create new project
await config();
return;
}

switch(answers.type) {
case "static":
config = staticConf(config, answers.name, process.cwd());
break;
}
// console.log(config);
})
}

if (existindex) {
inquirer
// Ask to overtime the file
const answers = await inquirer
.prompt([
{
type: "confirm",
name: "overwrite",
message: "index.html already exists! Would you like to open live server here ?",
default: false,
}
])
.then(answers => {
if (answers.overwrite) {
server(process.cwd())
} else{
console.log("Goodbye :)")
}
})
}
else{
config();
}
]);

if (!answers.overwrite) {
console.log("Goodbye :)");
return;
}

server(process.cwd());
}

main();