Skip to content

Commit

Permalink
chore: fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh3112 committed Mar 22, 2019
1 parent 7c8151b commit 11fad71
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ const QUESTIONS = [
const resolveTemplate = (path) => resolve(TEMPLATE_DIRECTORY, path);
const resolveUser = (path) => resolve(USER_DIRECTORY, path);
const l = (message) => { console.log(message); };
const info = (message) => { l(c.blueBright(i) + c.italic(` ${message}`)); }
const done = () => {l.greenBright("\u2713 Done"); };
const info = (message) => { l(c.bold("\n" + c.blue("i") + c.italic(` ${message}`))); }
const done = () => {l(c.greenBright("\u2713 Done")); };

function start() {
l(
`
${c.blueBright("webpack-scaffold-starter")}
------------------------
Start your webpack scaffold on the go
`
)
}
Expand All @@ -69,26 +68,26 @@ function scaffold(answers) {
packageJSON.description = answers.description;
packageJSON.author = answers.author;

let index = fs.readFileSync(resolveTemplate("./index.js"));
let index = fs.readFileSync(resolveTemplate("./index.js")).toString();
index = index.replace(/<name>/g, answers.name);
index = index.replace(/<description>/, ansewers.description);
index = index.replace(/<description>/, ansewers.author);
index = index.replace(/<description>/, answers.description);
index = index.replace(/<author>/, answers.author);

fs.writeFileSync(resolveUser("./package.json"), packageJSON);
fs.writeFileSync(resolveUser("./package.json"), JSON.stringify(packageJSON, null, 2));
fs.writeFileSync(resolveUser("./index.js"), index);
done();
}

function install() {
info("Installing Dependencies");
l(c.gray(" May take few minutes"));
l(c.gray(" May take few minutes..."));
execSync(`cd ${USER_DIRECTORY} && npm install --quiet`);
done();
}

(async() => {
start();
const answers = await question();
scaffold();
scaffold(answers);
install();
});
})();

0 comments on commit 11fad71

Please # to comment.