Skip to content

Commit

Permalink
change projectconfig flag
Browse files Browse the repository at this point in the history
  • Loading branch information
RobMayer committed Aug 8, 2023
1 parent 84a0b74 commit 51cfb7c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ttpg-scripts",
"version": "1.0.7",
"version": "1.1.0",
"description": "",
"bin": {
"ttpg-scripts": "./bin/index.js"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const runBuild = async () => {
Logger.error("Could not create build directory");
throw e;
}
if (config.project.template === "typescript") {
if (config.project.transpile || config.project.template === "typescript") {
Logger.notice("Transpiling typescript");
try {
await spawnTranspiler(`./build/`);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const runDev = async () => {
throw e;
}
}
if (config.project.template === "typescript") {
if (config.project.transpile || config.project.template === "typescript") {
Logger.notice("Transpiling typescript");
try {
await spawnTranspiler(`./dev/${config.project.slug}_dev/Scripts/`);
Expand Down
17 changes: 14 additions & 3 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export type Config = {
name: string;
slug: string;
version: string;
template: "javascript" | "typescript";
transpile: boolean;
template?: "javascript" | "typescript";
guid: {
dev: string;
prd: string;
Expand Down Expand Up @@ -148,9 +149,19 @@ export const assertSetup = async (): Promise<void> => {
};

export const loadConfig = async (): Promise<Config> => {
const local: Config["local"] = JSON.parse(await fs.readFile(path.resolve("./ttpgcfg.local.json"), "utf8"));
let project: Config["project"] = JSON.parse(await fs.readFile(path.resolve("./ttpgcfg.project.json"), "utf8"));

if (project.template && !("transpiler" in project)) {
project.transpile = project.template === "typescript";
const { template, ...newProject } = project;
project = newProject;
await fs.writeFile(path.resolve("./ttpgcfg.project.json"), JSON.stringify(project), "utf-8");
}

return {
local: JSON.parse(await fs.readFile(path.resolve("./ttpgcfg.local.json"), "utf8")),
project: JSON.parse(await fs.readFile(path.resolve("./ttpgcfg.project.json"), "utf8")),
local,
project,
};
};

Expand Down

0 comments on commit 51cfb7c

Please sign in to comment.