Skip to content

Commit

Permalink
Merge pull request #28 from roeeyn/hotfix/templates-path-bug
Browse files Browse the repository at this point in the history
Hotfix/templates path bug
  • Loading branch information
roeeyn authored Jun 14, 2022
2 parents c76722a + ac25b78 commit 75da358
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"start": "npm run build && npm i -g && challenge-generator",
"test": "jest",
"version:output": "echo \"export const version: string = \"'\"'\"$(cat package.json | jq -r '.version')\"'\"'\";\" > src/version.ts",
"build": "npm run version:output && npm run clean:some && tsc -p .",
"copy-files": "cp src/templates/run.templates.js.bash src/templates/run.templates.py.bash src/templates/run.templates.java.bash src/templates/testframework.templates.js src/templates/testframework.templates.py src/templates/testframework.templates.java lib/templates/",
"build": "npm run version:output && npm run clean:some && tsc -p . && npm run copy-files",
"format": "prettier -w .",
"format:check": "prettier -c . '!lib/**/*|README.md'",
"prepare": "npm run build",
Expand Down
9 changes: 6 additions & 3 deletions src/utils/files.utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import fs from "fs";
import { FileType, FileExtension, ProgrammingLanguage } from "../models";
import { minify } from "terser";
import { join } from "path";

const BIN_PATH = join(__dirname, "../../lib");

export type FileWriter = (
content: string,
Expand All @@ -23,7 +26,7 @@ export const createOrReplaceDir = (path: string): FileWriter => {
fileType: FileType,
fileExtension: FileExtension
) => {
fs.writeFileSync(`${path}/${fileType}${fileExtension}`, content);
fs.writeFileSync(join(`${path}`, `${fileType}${fileExtension}`), content);
};
};

Expand All @@ -40,7 +43,7 @@ export const readTemplateTestFile = async (
minifyContent: Boolean = true
): Promise<string> => {
const templateContent: string = fs.readFileSync(
`src/templates/testframework.templates${fileExtension}`,
join(BIN_PATH, `templates`, `testframework.templates${fileExtension}`),
"utf8"
);

Expand All @@ -57,7 +60,7 @@ export const readTemplateTestFile = async (
*/
export const readTemplateRunFile = (fileExtension: FileExtension): string => {
return fs.readFileSync(
`src/templates/run.templates${fileExtension}.bash`,
join(BIN_PATH, `templates`, `run.templates${fileExtension}.bash`),
"utf8"
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version: string = "2.3.2";
export const version: string = "2.3.7";

0 comments on commit 75da358

Please sign in to comment.