Skip to content

Commit 1a74b68

Browse files
committed
add conditions in generateCode to automatically detect whether app is in dev or prod mode
1 parent 5e42915 commit 1a74b68

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

app/src/helperFunctions/generateCode.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,20 @@ const generateUnformattedCode = (
271271
const formatCode = (code: string) => {
272272
// in test environment, window.api is not defined,
273273
// so we reference original prettier format function instead
274-
// if (process.env.NODE_ENV === 'test') {
275-
// const { format } = require('prettier');
276-
// return format(code, {
277-
// singleQuote: true,
278-
// trailingComma: 'es5',
279-
// bracketSpacing: true,
280-
// jsxBracketSameLine: true,
281-
// parser: 'babel'
282-
// });
283-
// } else {
284-
// return window.api.formatCode(code);
285-
// }
274+
if (process.env.NODE_ENV === 'test') {
275+
const { format } = require('prettier');
276+
return format(code, {
277+
singleQuote: true,
278+
trailingComma: 'es5',
279+
bracketSpacing: true,
280+
jsxBracketSameLine: true,
281+
parser: 'babel'
282+
});
283+
} else if (process.env.NODE_ENV === 'production') {
284+
return window.api.formatCode(code);
285+
} else {
286286
return code;
287-
287+
}
288288
};
289289

290290
// generate code based on component hierarchy and then return the rendered code

0 commit comments

Comments
 (0)