Skip to content

Commit

Permalink
Add --rojo support
Browse files Browse the repository at this point in the history
  • Loading branch information
Fireboltofdeath committed Jul 2, 2022
1 parent d901d76 commit 103026c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/classes/transformState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,24 @@ export class TransformState {
private setupRojo() {
this.pathTranslator = createPathTranslator(this.program);

const rojoConfig = RojoResolver.findRojoConfigFilePath(this.currentDirectory);
if (rojoConfig.path !== undefined) {
const rojoContents = fs.readFileSync(rojoConfig.path, { encoding: "ascii" });
const rojoArgvIndex = process.argv.findIndex((v) => v === "--rojo");
const rojoArg = process.argv[rojoArgvIndex + 1];

let rojoConfig: string | undefined;
if (rojoArg && rojoArg !== "") {
rojoConfig = path.resolve(rojoArg);
} else {
rojoConfig = RojoResolver.findRojoConfigFilePath(this.currentDirectory).path;
}

if (rojoConfig !== undefined) {
const rojoContents = fs.readFileSync(rojoConfig, { encoding: "ascii" });
const sum = crypto.createHash("md5").update(rojoContents).digest("hex");

if (sum === Cache.rojoSum) {
this.rojoResolver = Cache.rojoResolver;
} else {
this.rojoResolver = RojoResolver.fromPath(rojoConfig.path);
this.rojoResolver = RojoResolver.fromPath(rojoConfig);
Cache.rojoSum = sum;
Cache.rojoResolver = this.rojoResolver;
}
Expand Down

0 comments on commit 103026c

Please sign in to comment.