Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/commands/firebase-init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "../../templates";

import { Intro } from '../../utils/interactiveOutputs';
import { prettify } from "../../utils/formatter";

const createFolder = (folderPath) => {
fs.mkdirSync(
Expand All @@ -30,7 +31,7 @@ const createFolder = (folderPath) => {
const createFile = (filePath, fileContent) => {
fs.writeFile(
process.cwd() + filePath,
fileContent,
prettify(fileContent),
(error) => {
if (error) {
console.log("ERROR OCCURED:", error);
Expand All @@ -54,6 +55,8 @@ const getPages = (path) => {
const content = fs.readFileSync(x);
let y = content.toString().match(/export default ([\s\S]*?);/);
y = y[1].replace(/\s/g, '').replace('{','').replace('}','').split(',');
// Filter out falsy values (empty strings) that can cause problems
y = y.filter(Boolean);
let pages = []
y.forEach(object => {
let tmp = object.split(":");
Expand Down
10 changes: 6 additions & 4 deletions src/commands/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
import { Intro } from "../../utils/interactiveOutputs";
import firebaseInit from '../firebase-init';

import { prettify } from "../../utils/formatter";

const createFolder = (path, dir) => {
fs.mkdirSync(
process.cwd() + dir + "/src" + path,
Expand All @@ -28,7 +30,7 @@ const createFolder = (path, dir) => {
const createAppFile = (pages, path) => {
fs.writeFile(
process.cwd() + path + `/src/App.js`,
appTemplate(pages),
prettify(appTemplate(pages)),
(error) => {
if (error) {
console.log("ERROR OCCURED:", error);
Expand All @@ -43,7 +45,7 @@ const createAppFile = (pages, path) => {
const createComponentFile = (component, path) => {
fs.writeFile(
process.cwd() + path + `/src/components/${component}.js`,
componentTemplate(component),
prettify(componentTemplate(component)),
(error) => {
if (error) {
console.log("ERROR OCCURED:", error);
Expand All @@ -58,7 +60,7 @@ const createComponentFile = (component, path) => {
const createPageFile = (component, path) => {
fs.writeFile(
process.cwd() + path + `/src/pages/${component}.js`,
componentTemplate(component),
prettify(componentTemplate(component)),
(error) => {
if (error) {
console.log("ERROR OCCURED:", error);
Expand All @@ -73,7 +75,7 @@ const createPageFile = (component, path) => {
const createRouteFile = (pages, path) => {
fs.writeFile(
process.cwd() + path + `/src/routes/index.js`,
routesTemplate(pages),
prettify(routesTemplate(pages)),
(error) => {
if (error) {
console.log("ERROR OCCURED:", error);
Expand Down
2 changes: 1 addition & 1 deletion src/templates/firebase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const resetPassword = (email) => {
`

const providerAuthTemplate = (name) => `
const ${name}Signin = () => {
const ${name}Signin = async () => {
try {
await auth.signInWithPopup(${name}Provider).then(async user => {
if(user.additionalUserInfo.isNewUser){
Expand Down
3 changes: 3 additions & 0 deletions src/utils/formatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import prettier from "prettier";

export const prettify = str => prettier.format(str, { parser: 'babel' });